Skip to content
Snippets Groups Projects
Commit cb6388bb authored by wlott's avatar wlott
Browse files

Added sunos support.

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