/* netboot * * $Log: misc.c,v $ * Revision 1.1 1993/07/08 16:04:03 brezak * Diskless boot prom code from Jim McKim (mckim@lerc.nasa.gov) * * Revision 1.3 1993/06/30 20:17:54 mckim * Exit to BIOS in exit(). * * Revision 1.2 1993/06/08 14:22:37 mckim * Fast in line assembly bcopy(), bzero(). * * Revision 1.1.1.1 1993/05/28 11:41:07 mckim * Initial version. * */ #include "proto.h" #if defined(DEBUG) void DUMP_STRUCT(char *s, u_char *p, u_int ps) { int i; printf("struct %s (@0x%x %d bytes): ", s, p, ps); for (i=0; i> 4) * 10 + (arg & 0x0F); } u_long timer(void) { /* TBD - replace with StartCountdown()/CountdownAtZero() routines, isolate the span-midnight problem to inside these routines */ /* * Return the current time in seconds */ u_long sec, min, hour; /* BIOS time is stored in bcd */ getrtc(&hour, &min, &sec); sec = bcd2dec(sec); min = bcd2dec(min); hour = bcd2dec(hour); #if 0 printe("time h%d m%d s%d = sum%d\n", hour, min, sec, hour * 3600L + min * 60L + sec); #endif return hour * 3600L + min * 60L + sec; } /* * Simple random generator */ static u_long next = 1; void srand(u_int seed) { next = seed; } int rand(void) { next = next * 1103515245L + 12345; return (u_int)(next / 65536) % 32768; } u_short GetMemSize(u_short s) { #ifdef USE_BIOS u_short result; asm(" push %%ebx mov %1, %%ebx call _prot_to_real cmpb $0x1, %%bl .byte 0x66 je 1f sti int $0x12 cli .byte 0x66 jmp 2f 1: movb $0x88, %%ah sti int $0x15 cli 2: mov %%eax, %%ebx .byte 0x66 call _real_to_prot mov %%bx, %0 pop %%ebx " : "=g" (result) : "g" (s)); return result; #else u_long result; if (s) result = ((u_long)ReadRtcRam(RTC_EXPMEM_HI)<<8) + ReadRtcRam(RTC_EXPMEM_LO); else result = ((u_long)ReadRtcRam(RTC_BASEMEM_HI)<<8) + ReadRtcRam(RTC_BASEMEM_LO); return result; #endif } void ResetCpu(void) { #ifdef USE_BIOS asm(" call _prot_to_real # enter real mode int $0x19 " ); #else while (inb(0x64)&2); /* wait input ready */ outb(0x64, 0xFE); /* Reset Command */ #endif }