/* * GeekOS C code entry point * Copyright (c) 2001,2003,2004 David H. Hovemeyer * Copyright (c) 2003, Jeffrey K. Hollingsworth * Copyright (c) 2004, Iulian Neamtiu * $Revision: 1.30 $ * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SPEAKER_PORT 0x61 void Buzz(unsigned delay, unsigned num) { volatile int x; int i,j; unsigned char init; init=In_Byte(SPEAKER_PORT); for (i=0;i0x%.2x\n", *(char*)src); break; case 2: PrintBoth(">0x%.4x\n", *(ushort_t*)src); break; case 4: PrintBoth(">0x%.8x\n", *(uint_t*)src); break; default: break; } // SerialMemDump(src, length); return length; } void BuzzVM() { int x; int j; unsigned char init; #if 0 __asm__ __volatile__ ( "popf" ); #endif PrintBoth("Starting To Buzz\n"); init=MyIn_Byte(SPEAKER_PORT); while (1) { MyOut_Byte(SPEAKER_PORT, init|0x2); for (j=0;j<1000000;j++) { x+=j; } MyOut_Byte(SPEAKER_PORT, init); for (j=0;j<1000000;j++) { x+=j; } } } void Buzzer(ulong_t arg) { ulong_t *doIBuzz = (ulong_t*)arg; while (1) { // Quick and dirty hack to save my hearing... // I'm not too worried about timing, so I'll deal with concurrency later... if (*doIBuzz == 1) { Buzz(1000000, 10); } } } void Keyboard_Listener(ulong_t arg) { ulong_t * doIBuzz = (ulong_t*)arg; Keycode key_press; Print("Press F4 to turn on/off the speaker\n"); while ((key_press = Wait_For_Key())) { if (key_press == KEY_F4) { Print("\nToggling Speaker Port\n"); SerialPrintLevel(100,"\nToggling Speaker Port\n"); *doIBuzz = (*doIBuzz + 1) % 2; } else if (key_press == KEY_F5) { Print("\nMachine Restart\n"); SerialPrintLevel(100,"\nMachine Restart\n"); machine_real_restart(); } } return; } extern char BSS_START, BSS_END; extern char end; /* This is an ugly hack to get at the VM memory */ ulong_t vm_range_start; ulong_t vm_range_end; ulong_t guest_kernel_start; ulong_t guest_kernel_end; /* ** */ int AllocateAndMapPagesForRange(uint_t start, uint_t length, pte_t template_pte) { uint_t address; for (address=start;address