diff --git a/ldb/save.c b/ldb/save.c index e4b21b33bddf35948f770249612c3427733d8822..200e80b2faf673f8c20b4cbac150d1a211d2968e 100644 --- a/ldb/save.c +++ b/ldb/save.c @@ -1,10 +1,10 @@ #include <stdio.h> #include <signal.h> #include <sys/file.h> -#include <mach.h> -#include "lisp.h" #include "ldb.h" +#include "os.h" +#include "lisp.h" #include "core.h" #include "globals.h" #include "lispregs.h" @@ -71,7 +71,7 @@ lispobj *addr, *end; data = write_bytes((char *)addr, bytes); putw(data, save_file); - putw((vm_address_t)addr / CORE_PAGESIZE, save_file); + putw((os_vm_address_t)((long)addr / CORE_PAGESIZE), save_file); putw((bytes + CORE_PAGESIZE - 1) / CORE_PAGESIZE, save_file); } @@ -80,8 +80,8 @@ char *name, *start, *end; { long len; - start = (char *)trunc_page((vm_address_t)start); - end = (char *)round_page((vm_address_t)end); + start = (char *)os_trunc_to_page((os_vm_address_t)start); + end = (char *)os_round_up_to_page((os_vm_address_t)end); len = end-start; @@ -124,7 +124,7 @@ struct sigcontext *context; fwrite(&ms, sizeof(ms), 1, save_file); } -static save_handler(signal, code, context) +static void save_handler(signal, code, context) int signal, code; struct sigcontext *context; { @@ -209,33 +209,31 @@ char *filename; /* State that must be preserved between load and restore. */ static struct sigcontext context; -static vm_address_t number_stack; +static os_vm_address_t number_stack; -static vm_address_t map_stack(fd, start, end, data_page, name) +static os_vm_address_t map_stack(fd, start, end, data_page, name) int fd; -vm_address_t start, end; +os_vm_address_t start, end; long data_page; char *name; { - vm_size_t len; - kern_return_t res; + os_vm_size_t len; - start = trunc_page(start); - len = round_page(end) - start; + start = os_trunc_to_page(start); + len = os_round_up_to_page(end) - start; if (len != 0) { if (start == NULL) { - res = vm_allocate(task_self(), &start, len, TRUE); - if (res != KERN_SUCCESS) { - fprintf(stderr, "Could not allocate stageing area for the %s stack: %s.\n", name, mach_error_string(res)); - } + start = os_validate(start, len); + if(start==NULL) + fprintf(stderr, "Could not allocate stageing area for the %s stack.\n", name); } #ifdef PRINTNOISE printf("Mapping %d bytes onto the %s stack at 0x%08x.\n", len, name, start); #endif - os_map(fd, (1+data_page)*CORE_PAGESIZE, start, len); + start=os_map(fd, (1+data_page)*CORE_PAGESIZE, start, len); } return start; @@ -263,44 +261,44 @@ struct machine_state *ms; read(fd, &context, sizeof(context)); map_stack(fd, - (vm_address_t)control_stack, - (vm_address_t)current_control_stack_pointer, + (os_vm_address_t)control_stack, + (os_vm_address_t)current_control_stack_pointer, ms->control_stack_page, "Control"); map_stack(fd, - (vm_address_t)binding_stack, + (os_vm_address_t)binding_stack, #ifndef ibmrt - (vm_address_t)current_binding_stack_pointer, + (os_vm_address_t)current_binding_stack_pointer, #else - (vm_address_t)SymbolValue(BINDING_STACK_POINTER), + (os_vm_address_t)SymbolValue(BINDING_STACK_POINTER), #endif ms->binding_stack_page, "Binding"); number_stack = map_stack(fd, - (vm_address_t)NULL, - round_page((vm_address_t)number_stack_start) - (vm_address_t)context.sc_regs[NSP], + (os_vm_address_t)NULL, + os_round_up_to_page((os_vm_address_t)number_stack_start) - (os_vm_address_t)context.sc_regs[NSP], ms->number_stack_page, "Number"); } -static restore_handler(signal, code, old_context) +static void restore_handler(signal, code, old_context) int signal, code; struct sigcontext *old_context; { - vm_size_t len; - vm_address_t nsp; + os_vm_size_t len; + os_vm_address_t nsp; /* We have to move the number stack into place. */ - nsp = trunc_page((vm_address_t)context.sc_regs[NSP]); - len = (vm_address_t)number_stack_start - nsp; + nsp = os_trunc_to_page((os_vm_address_t)context.sc_regs[NSP]); + len = (os_vm_address_t)number_stack_start - nsp; #ifdef PRINTNOISE printf("Moving the number stack from 0x%08x to 0x%08x.\n", number_stack, nsp); #endif bcopy(number_stack, nsp, len); - vm_deallocate(task_self(), number_stack, round_page(len)); + os_invalidate(number_stack, os_round_up_to_page(len)); #ifndef ibmrt sigreturn(&context); diff --git a/ldb/sparc-assem.s b/ldb/sparc-assem.s index ef3f811a44bffada4a8e229b03b9aa8f9f8a73e5..b99bfbb918da95ccc12639e22ebb2ca71fdb3203 100644 --- a/ldb/sparc-assem.s +++ b/ldb/sparc-assem.s @@ -309,7 +309,12 @@ __sigtramp: #define SIGNUMOFF SCOFF+SCSIZE #define CODEOFF SCOFF+SCSIZE+4 #define ADDROFF SCOFF+SCSIZE+12 + +#ifdef MACH #define OSCOFF ADDROFF +#else +#define OSCOFF SCOFF+SCSIZE+16 +#endif ! Allocate space for our sigcontext. sub %sp, SCSIZE+SA(MINFRAME)-64, %sp @@ -319,10 +324,10 @@ __sigtramp: ! been trashed. But luckly, they have been saved on the stack. ! So we need to extract the saved stack pointer from the sigcontext ! to determine where they are. - std %0, [%sp+IREGSOFF] - std %2, [%sp+IREGSOFF+8] - std %4, [%sp+IREGSOFF+16] - std %6, [%sp+IREGSOFF+24] + std %g0, [%sp+IREGSOFF] + std %g2, [%sp+IREGSOFF+8] + std %g4, [%sp+IREGSOFF+16] + std %g6, [%sp+IREGSOFF+24] std %o0, [%sp+IREGSOFF+32] ld [%sp + OSCOFF+8], %o0 std %o2, [%sp+IREGSOFF+40] @@ -330,22 +335,22 @@ __sigtramp: st %o0, [%sp+IREGSOFF+56] st %o7, [%sp+IREGSOFF+60] - ldd [%o0], %16 - ldd [%o0+8], %18 - ldd [%o0+16], %20 - ldd [%o0+24], %22 - ldd [%o0+32], %24 - ldd [%o0+40], %26 - ldd [%o0+48], %28 - ldd [%o0+56], %30 - std %16, [%sp+IREGSOFF+64] - std %18, [%sp+IREGSOFF+72] - std %20, [%sp+IREGSOFF+80] - std %22, [%sp+IREGSOFF+88] - std %24, [%sp+IREGSOFF+96] - std %26, [%sp+IREGSOFF+104] - std %28, [%sp+IREGSOFF+112] - std %30, [%sp+IREGSOFF+120] + ldd [%o0], %l0 + ldd [%o0+8], %l2 + ldd [%o0+16], %l4 + ldd [%o0+24], %l6 + ldd [%o0+32], %i0 + ldd [%o0+40], %i2 + ldd [%o0+48], %i4 + ldd [%o0+56], %i6 + std %l0, [%sp+IREGSOFF+64] + std %l2, [%sp+IREGSOFF+72] + std %l4, [%sp+IREGSOFF+80] + std %l6, [%sp+IREGSOFF+88] + std %i0, [%sp+IREGSOFF+96] + std %i2, [%sp+IREGSOFF+104] + std %i4, [%sp+IREGSOFF+112] + std %i6, [%sp+IREGSOFF+120] ! Copy the original sigcontext down to our sigcontext. ld [%sp + OSCOFF], %l0 @@ -439,32 +444,32 @@ _sigreturn: ! The locals and in are restored from the stack, so we have to put ! them there. ld [%o0 + 8], %o1 - ldd [%o0 + 32+(16*4)], %16 - ldd [%o0 + 32+(18*4)], %18 - ldd [%o0 + 32+(20*4)], %20 - ldd [%o0 + 32+(22*4)], %22 - ldd [%o0 + 32+(24*4)], %24 - ldd [%o0 + 32+(26*4)], %26 - ldd [%o0 + 32+(28*4)], %28 - ldd [%o0 + 32+(30*4)], %30 - std %16, [%o1 + (0*4)] - std %18, [%o1 + (2*4)] - std %20, [%o1 + (4*4)] - std %22, [%o1 + (6*4)] - std %24, [%o1 + (8*4)] - std %26, [%o1 + (10*4)] - std %28, [%o1 + (12*4)] - std %30, [%o1 + (14*4)] + ldd [%o0 + 32+(16*4)], %l0 + ldd [%o0 + 32+(18*4)], %l2 + ldd [%o0 + 32+(20*4)], %l4 + ldd [%o0 + 32+(22*4)], %l6 + ldd [%o0 + 32+(24*4)], %i0 + ldd [%o0 + 32+(26*4)], %i2 + ldd [%o0 + 32+(28*4)], %i4 + ldd [%o0 + 32+(30*4)], %i6 + std %l0, [%o1 + (0*4)] + std %l2, [%o1 + (2*4)] + std %l4, [%o1 + (4*4)] + std %l6, [%o1 + (6*4)] + std %i0, [%o1 + (8*4)] + std %i2, [%o1 + (10*4)] + std %i4, [%o1 + (12*4)] + std %i6, [%o1 + (14*4)] ! Restore the globals and outs. Don't restore %g1, %o0, or %sp ! 'cause they get restored from the sigcontext. - ldd [%o0 + 32+(2*4)], %2 - ldd [%o0 + 32+(4*4)], %4 - ldd [%o0 + 32+(6*4)], %6 - ld [%o0 + 32+(9*4)], %9 - ldd [%o0 + 32+(10*4)], %10 - ldd [%o0 + 32+(12*4)], %12 - ld [%o0 + 32+(15*4)], %15 + ldd [%o0 + 32+(2*4)], %g2 + ldd [%o0 + 32+(4*4)], %g4 + ldd [%o0 + 32+(6*4)], %g6 + ld [%o0 + 32+(9*4)], %o1 + ldd [%o0 + 32+(10*4)], %o2 + ldd [%o0 + 32+(12*4)], %o4 + ld [%o0 + 32+(15*4)], %o7 set 139, %g1 ! sigcleanup system call t 0