2 * This is the ARM Linux incarnation of arch-dependent OS-dependent
3 * routines. See also "linux-os.c".
7 * This software is part of the SBCL system. See the README file for
10 * This software is derived from the CMU CL system, which was
11 * written at Carnegie Mellon University and released into the
12 * public domain. The software is in the public domain and is
13 * provided with absolutely no warranty. See the COPYING and CREDITS
14 * files for more information.
18 #include <sys/param.h>
20 #include "genesis/sbcl.h"
24 #include "interrupt.h"
28 #include <sys/types.h>
37 int arch_os_thread_init(struct thread
*thread
) {
39 /* Signal handlers are normally run on the main stack, but we've
40 * swapped stacks, require that the control stack contain only
41 * boxed data, and expands upwards while the C stack expands
43 sigstack
.ss_sp
= calc_altstack_base(thread
);
44 sigstack
.ss_flags
= 0;
45 sigstack
.ss_size
= calc_altstack_size(thread
);
46 if(sigaltstack(&sigstack
,0)<0)
47 lose("Cannot sigaltstack: %s",strerror(errno
));
49 return 1; /* success */
51 int arch_os_thread_cleanup(struct thread
*thread
) {
52 return 1; /* success */
55 os_context_register_t
*
56 os_context_register_addr(os_context_t
*context
, int offset
)
58 return (os_context_register_t
*)&(context
->uc_mcontext
.regs
[offset
]);
61 os_context_register_t
*
62 os_context_lr_addr(os_context_t
*context
)
64 return os_context_register_addr(context
, reg_LR
);
68 os_context_sigmask_addr(os_context_t
*context
)
70 return &(context
->uc_sigmask
);
73 os_context_register_t
*
74 os_context_flags_addr(os_context_t
*context
)
76 return (os_context_register_t
*)&(context
->uc_mcontext
.pstate
);
80 os_restore_fp_control(os_context_t
*context
)
82 /* FIXME: Implement. */
85 os_context_register_t
*
86 os_context_float_register_addr(os_context_t
*context
, int offset
)
88 /* KLUDGE: neither glibc nor the kernel can settle down on a name,
89 the kernel used __reserved, now glibc uses __glibc_reserved1.
90 Hardcode it until they make up their mind */
91 return (os_context_register_t
*)
92 &((struct fpsimd_context
*)((uintptr_t)&context
->uc_mcontext
+ 288))->vregs
[offset
];
96 os_flush_icache(os_vm_address_t address
, os_vm_size_t length
)
98 os_vm_address_t end_address
99 = (os_vm_address_t
)(((uintptr_t) address
) + length
);
100 __clear_cache(address
, end_address
);
103 // To avoid "Missing required foreign symbol" errors in os_link_runtime()
104 // the executable must actually depend on libm. It would not require libm,
105 // despite -lm in the link step, if there is no reference to a libm symbol
106 // observable to the linker. Any one symbol suffices to resolve all of them.
108 const long libm_anchor
= (long)acos
;
110 #include <sys/types.h>
111 #include <sys/stat.h>
113 int _stat(const char *pathname
, struct stat
*sb
) {return stat(pathname
, sb
); }
114 int _lstat(const char *pathname
, struct stat
*sb
) { return lstat(pathname
, sb
); }
115 int _fstat(int fd
, struct stat
*sb
) { return fstat(fd
, sb
); }