13 #include "interrupt.h"
17 #include "target-arch-os.h"
19 #define OS_VM_DEFAULT_PAGESIZE 8192
21 long os_vm_page_size=(-1);
22 static long os_real_page_size=(-1);
24 static os_vm_size_t real_page_size_difference=0;
29 /* I do not understand this at all. FIXME. */
30 os_vm_page_size = os_real_page_size = sysconf(_SC_PAGESIZE);
32 if(os_vm_page_size>OS_VM_DEFAULT_PAGESIZE){
33 fprintf(stderr,"os_init: Pagesize too large (%d > %d)\n",
34 os_vm_page_size,OS_VM_DEFAULT_PAGESIZE);
38 * we do this because there are apparently dependencies on
39 * the pagesize being OS_VM_DEFAULT_PAGESIZE somewhere...
40 * but since the OS doesn't know we're using this restriction,
41 * we have to grovel around a bit to enforce it, thus anything
42 * that uses real_page_size_difference.
44 /* FIXME: Is this still true? */
45 real_page_size_difference=OS_VM_DEFAULT_PAGESIZE-os_vm_page_size;
46 os_vm_page_size=OS_VM_DEFAULT_PAGESIZE;
51 os_validate(os_vm_address_t addr, os_vm_size_t len)
53 int flags = MAP_PRIVATE | MAP_NORESERVE | MAP_ANON;
58 addr = mmap(addr, len,
62 if (addr == MAP_FAILED) {
64 lose ("Error in mmap(..)");
71 os_invalidate(os_vm_address_t addr, os_vm_size_t len)
73 if(munmap((void*) addr, len) == -1)
80 os_map(int fd, int offset, os_vm_address_t addr, os_vm_size_t len)
83 addr = mmap(addr, len,
85 MAP_PRIVATE | MAP_FIXED,
88 if (addr == MAP_FAILED) {
90 lose("Unexpedted mmap(..) failure");
97 os_protect(os_vm_address_t address, os_vm_size_t length, os_vm_prot_t prot)
99 if(mprotect((void*)address, length, prot) == -1) {
105 in_range_p(os_vm_address_t a, lispobj sbeg, size_t slen)
107 char* beg = (char*) sbeg;
108 char* end = (char*) sbeg + slen;
109 char* adr = (char*) a;
110 return (adr >= beg && adr < end);
114 is_valid_lisp_addr(os_vm_address_t addr)
116 /* Just assume address is valid if it lies within one of the known
117 spaces. (Unlike sunos-os which keeps track of every valid page.) */
118 return ( in_range_p(addr, READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE)
119 || in_range_p(addr, STATIC_SPACE_START , STATIC_SPACE_SIZE )
120 || in_range_p(addr, DYNAMIC_0_SPACE_START, DYNAMIC_SPACE_SIZE )
121 || in_range_p(addr, DYNAMIC_1_SPACE_START, DYNAMIC_SPACE_SIZE )
122 || in_range_p(addr, CONTROL_STACK_START , CONTROL_STACK_SIZE )
123 || in_range_p(addr, BINDING_STACK_START , BINDING_STACK_SIZE ));
130 #error "GENCGC is not yet supported (presumably on x86 solaris?)"
135 sigsegv_handler(int signal, siginfo_t *info, void* void_context)
137 os_context_t *context = arch_os_get_context(&void_context);
138 os_vm_address_t addr;
140 addr = arch_get_bad_addr(signal, info, context);
141 /* There's some complicated recovery code in linux-os.c here
142 that I'm currently too confused to understand. Fixme. */
143 if(!interrupt_maybe_gc(signal, info, context)) {
144 interrupt_handle_now(signal, info, context);
151 os_install_interrupt_handlers()
153 undoably_install_low_level_interrupt_handler(SIGSEGV,sigsegv_handler);