2 * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/irix-os.c,v 1.7 2011/09/01 05:18:26 rtoy Exp $
4 * OS-dependent routines. This file (along with os.h) exports an
5 * OS-independent interface to the operating system VM facilities.
6 * Suprisingly, this interface looks a lot like the Mach interface
7 * (but simpler in some places). For some operating systems, a subset
8 * of these functions will have to be emulated.
10 * This is the IRIX version. By Sean Hallgren.
20 #include "interrupt.h"
22 #include <sys/types.h>
23 #include <sys/sysinfo.h>
28 os_vm_size_t os_vm_page_size = (-1);
33 os_init0(const char *argv[], const char *envp[])
37 os_init(const char *argv[], const char *envp[])
39 zero_fd = open("/dev/zero", O_RDONLY);
40 os_vm_page_size = getpagesize();
43 os_vm_address_t os_validate(os_vm_address_t addr, os_vm_size_t len)
45 int flags = MAP_PRIVATE | MAP_AUTORESRV;
48 printf("os_validate: addr = %x, len = %x\n", addr, len);
54 if ((addr = mmap(addr, len, OS_VM_PROT_ALL, flags, zero_fd, 0)) ==
55 (os_vm_address_t) - 1)
62 os_invalidate(os_vm_address_t addr, os_vm_size_t len)
65 printf("os_invalidate: addr = %x, len = %x\n", addr, len);
68 if (munmap(addr, len) == -1)
73 os_map(int fd, int offset, os_vm_address_t addr, os_vm_size_t len)
76 printf("os_map: fd = %d, offset = %d, addr = %x, len = %x\n", fd, offset,
80 if ((addr = mmap(addr, len, OS_VM_PROT_ALL, MAP_PRIVATE | MAP_FIXED, fd,
81 (off_t) offset)) == (os_vm_address_t) - 1)
88 sanctify_for_execution(os_vm_address_t addr, os_vm_size_t len)
90 char *end_addr = addr + len;
92 addr = os_trunc_to_page(addr);
93 len = end_addr - addr;
95 if (mprotect(addr, len, OS_VM_PROT_ALL) == -1)
100 os_flush_icache(os_vm_address_t address, os_vm_size_t length)
102 sanctify_for_execution(address, length);
106 os_protect(os_vm_address_t addr, os_vm_size_t len, os_vm_prot_t prot)
108 if (mprotect(addr, len, prot) == -1)
112 boolean valid_addr(os_vm_address_t addr)
117 sigbus_handler(int signal, int code, struct sigcontext *context)
119 if (!interrupt_maybe_gc(signal, code, context))
120 interrupt_handle_now(signal, code, context);
124 sigsegv_handler(int signal, int code, struct sigcontext *context)
126 if (!interrupt_maybe_gc(signal, code, context))
127 interrupt_handle_now(signal, code, context);
131 os_install_interrupt_handlers(void)
133 interrupt_install_low_level_handler(SIGSEGV, sigsegv_handler);
134 interrupt_install_low_level_handler(SIGBUS, sigbus_handler);