/* $NetBSD: machdep.c,v 1.2 1994/10/26 09:11:51 cgd Exp $ */ #include #include #include #include "machine/obio.h" #include "machine/pte.h" #include "machine/control.h" #include "machine/idprom.h" #include "../sun3/intersil7170.h" #include "netboot/exec_var.h" #include "config.h" extern int debug; vm_offset_t high_segment_free_start = 0; vm_offset_t high_segment_free_end = 0; vm_offset_t avail_start; volatile struct intersil7170 *clock_addr = 0; void high_segment_init() { vm_offset_t va; high_segment_free_start = MONSHORTSEG; high_segment_free_end = MONSHORTPAGE; for (va = high_segment_free_start; va < high_segment_free_end; va+= NBPG) set_pte(va, PG_INVAL); } vm_offset_t high_segment_alloc(npages) int npages; { int i; vm_offset_t va, tmp; if (npages == 0) panic("panic: request for high segment allocation of 0 pages"); if (high_segment_free_start == high_segment_free_end) return NULL; va = high_segment_free_start + (npages*NBPG); if (va > high_segment_free_end) return NULL; tmp = high_segment_free_start; high_segment_free_start = va; return tmp; } #define intersil_command(run, interrupt) \ (run | interrupt | INTERSIL_CMD_FREQ_32K | INTERSIL_CMD_24HR_MODE | \ INTERSIL_CMD_NORMAL_MODE) void clock_start() { clock_addr = (struct intersil7170 *) obio_alloc((caddr_t) OBIO_CLOCK, OBIO_CLOCK_SIZE, OBIO_WRITE); if (!clock_addr) panic("clock_init: no obio space for clock"); printf("about to turn on clock\n"); clock_addr->command_reg = intersil_command(INTERSIL_CMD_RUN, INTERSIL_CMD_IDISABLE); printf("clock on\n"); } u_long gettenths() { char csecs; u_long val; val = 0; csecs = clock_addr->counters.csecs; val = csecs/10; val += clock_addr->counters.seconds*10; val += clock_addr->counters.minutes*60*10; val += clock_addr->counters.hours*60*60*10; csecs = clock_addr->counters.csecs; return val; } time_t getsecs() { return gettenths()/10; } void machdep_nfsboot() { extern char edata[], end[]; printf("before bzero\n"); printf("edata %x, end-edata %x\n", edata, end - edata); bzero(edata, end - edata); printf("hi\n"); high_segment_init(); printf("high_segment_initialized\n"); /* get va afer netboot */ avail_start = sun3_round_page(end); avail_start+= NBPG; /* paranoia */ printf("pre_clock_start\n"); clock_start(); printf("hi there\n"); nfs_boot(NULL, "le"); } void machdep_stop() { mon_exit_to_mon(); } void machdep_common_ether(ether) unsigned char *ether; { static int ether_init = 0; static struct idprom idprom_copy; unsigned char *p; if (!ether_init) { int i; for (i= 0, p = (char *) &idprom_copy; itext_info.segment_addr - FIXED_LOAD_ADDR; ev->text_info.segment_va = FIXED_LOAD_ADDR; ev->data_info.segment_va = ev->data_info.segment_addr - correction; ev->bss_info.segment_va = ev->bss_info.segment_addr - correction; if (ev->nfs_disklessp) ev->nfs_disklessp = (caddr_t) (((unsigned char) ev->nfs_disklessp) - correction); ev->real_entry_point = ev->entry_point - correction; if ((ev->bss_info.segment_va + ev->bss_info.segment_size) > BOOT_LOAD_ADDR) panic("netboot: kernel image would overwrite bootstrap code"); }