/** * 아래 함수는 C 언어 커널의 시작 부분임 */ void Main( void ) { int iCursorX, iCursorY; // 콘솔을 먼저 초기화한 후, 다음 작업을 수행 kInitializeConsole( 0, 10 ); kPrintf( "Switch To IA-32e Mode Success~!!\n" ); kPrintf( "IA-32e C Language Kernel Start..............[Pass]\n" ); kPrintf( "Initialize Console..........................[Pass]\n" ); // 부팅 상황을 화면에 출력 kGetCursor( &iCursorX, &iCursorY ); kPrintf( "GDT Initialize And Switch For IA-32e Mode...[ ]" ); kInitializeGDTTableAndTSS(); kLoadGDTR( GDTR_STARTADDRESS ); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); kPrintf( "TSS Segment Load............................[ ]" ); kLoadTR( GDT_TSSSEGMENT ); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); kPrintf( "IDT Initialize..............................[ ]" ); kInitializeIDTTables(); kLoadIDTR( IDTR_STARTADDRESS ); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); kPrintf( "Total RAM Size Check........................[ ]" ); kCheckTotalRAMSize(); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass], Size = %d MB\n", kGetTotalRAMSize() ); kPrintf( "TCB Pool And Scheduler Initialize...........[Pass]\n" ); iCursorY++; kInitializeScheduler(); // 1ms당 한번씩 인터럽트가 발생하도록 설정 kInitializePIT( MSTOCOUNT( 1 ), 1 ); kPrintf( "Keyboard Activate And Queue Initialize......[ ]" ); // 키보드를 활성화 if( kInitializeKeyboard() == TRUE ) { kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); kChangeKeyboardLED( FALSE, FALSE, FALSE ); } else { kSetCursor( 45, iCursorY++ ); kPrintf( "Fail\n" ); while( 1 ) ; } kPrintf( "PIC Controller And Interrupt Initialize.....[ ]" ); // PIC 컨트롤러 초기화 및 모든 인터럽트 활성화 kInitializePIC(); kMaskPICInterrupt( 0 ); kEnableInterrupt(); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); // 셸을 시작 kStartConsoleShell(); }
void Main( void ) { int iCursorX, iCursorY; kPrintString( 45, 10,"Pass" ); kInitializeConsole( 0, 11); kPrintf("Success to enter 64-bit C Kernel\n"); kPrintf("Console Initialization......................[Pass]\n"); // 부팅상황 kGetCursor( &iCursorX, &iCursorY ); kPrintf("GDT Initialize And Switch For 64bit Mode....[ ]"); kInitializeGDTTableAndTSS(); kLoadGDTR( GDTR_STARTADDRESS ); kSetCursor( 45, iCursorY++); kPrintf("Pass\n"); kPrintf("TSS Segment Load............................[ ]" ); kLoadTR( GDT_TSSSEGMENT ); kSetCursor( 45, iCursorY++); kPrintf("Pass\n"); kPrintf("IDT Initialize..............................[ ]" ); kInitializeIDTTables(); kLoadIDTR( IDTR_STARTADDRESS ); kSetCursor( 45, iCursorY++); kPrintf("Pass\n"); kPrintf("Total RAM Size Check........................[ ]" ); kCheckTotalRAMSize(); kSetCursor( 45, iCursorY++); kPrintf("Pass], Size = %d MB\n", kGetTotalRAMSize()); kPrintf("TCB Pool And Scheduler Initialize...........[Pass]\n" ); iCursorY++; kInitializeScheduler(); kPrintf("Dynamic Memory Initialize...................[Pass]\n"); iCursorY++; kInitializeDynamicMemory(); // 1ms 당 인터럽트 발생 kInitializePIT( MSTOCOUNT(1), 1 ); kPrintf("Keyboard Activation.........................[ ]" ); if( kInitializeKeyboard() == TRUE ) { kSetCursor( 45, iCursorY++); kPrintf("Pass\n"); kChangeKeyboardLED(FALSE, FALSE, FALSE); } else { kSetCursor( 45, iCursorY++); kPrintf("Fail\n"); while(1) { ; } } kPrintf("PIC Controller And Interrupt Initialize.....[ ]" ); kInitializePIC(); kMaskPICInterrupt( 0 ); kEnableInterrupt(); kSetCursor( 45, iCursorY++); kPrintf("Pass\n"); kPrintf("HDD Initialize..............................[ ]" ); if(kInitializeHDD() == TRUE) { kSetCursor( 45, iCursorY++); kPrintf("Pass\n"); } else { kSetCursor( 45, iCursorY++); kPrintf("Fail\n"); } kPrintf("File System Initialize......................[ ]" ); if(kInitializeFileSystem() == TRUE) { kSetCursor( 45, iCursorY++); kPrintf("Pass\n"); } else { kSetCursor( 45, iCursorY++); kPrintf("Fail\n"); } kCreateTask( TASK_FLAGS_LOWEST | TASK_FLAGS_IDLE | TASK_FLAGS_SYSTEM | TASK_FLAGS_THREAD , 0, 0, (QWORD) kIdleTask ); kStartConsoleShell(); }
// Bootstrap Processor용 C 언어 커널 엔트리 포인트 void main( void ) { int iCursorX, iCursorY; // 부트 로더에 있는 BSP 플래그를 읽어서 Application Processor이면 // 해당 코어용 초기화 함수로 이동 if(*((BYTE*)BOOTSTRAPPROCESSOR_FLAGADDESS)==0) { mainForApplicationProcessor(); } // Bootstrap Processor가 부팅을 완료했으므로, 0x7C09에 있는 Bootstrap Processor를 // 나타내는 플래그를 0으로 설정하여 Application Processor용으로 코드 실행 경로를 변경 *((BYTE*)BOOTSTRAPPROCESSOR_FLAGADDESS)=0; // 콘솔을 먼저 초기화한 후, 다음 작업을 수행 kInitializeConsole( 0, 10 ); kPrintf( "Switch To IA-32e Mode Success~!!\n" ); kPrintf( "IA-32e C Language Kernel Start..............[Pass]\n" ); kPrintf( "Initialize Console..........................[Pass]\n" ); // 부팅 상황을 화면에 출력 kGetCursor( &iCursorX, &iCursorY ); kPrintf( "GDT Initialize And Switch For IA-32e Mode...[ ]" ); kInitializeGDTTableAndTSS(); kLoadGDTR( GDTR_STARTADDRESS ); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); kPrintf( "TSS Segment Load............................[ ]" ); kLoadTR( GDT_TSSSEGMENT ); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); kPrintf( "IDT Initialize..............................[ ]" ); kInitializeIDTTables(); kLoadIDTR( IDTR_STARTADDRESS ); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); kPrintf( "Total RAM Size Check........................[ ]" ); kCheckTotalRAMSize(); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass], Size = %d MB\n", kGetTotalRAMSize() ); kPrintf("TCB Poll And Scheduler Initialize...........[Pass]\n"); iCursorY++; kInitializeScheduler(); // 동적 메모리 초기화 kPrintf("Dynamic Memory Initialize...................[Pass]\n"); iCursorY++; kInitializeDynamicMemory(); // 1ms당 한 번씩 인터럽트가 발생하도록 설정 kInitializePIT(MSTOCOUNT(1),1); kPrintf( "Keyboard Activate And Queue Initialize......[ ]" ); // 키보드를 활성화 if( kInitializeKeyboard() == TRUE ) { kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); kChangeKeyboardLED( FALSE, FALSE, FALSE ); } else { kSetCursor( 45, iCursorY++ ); kPrintf( "Fail\n" ); while( 1 ) ; } kPrintf( "PIC Controller And Interrupt Initialize.....[ ]" ); // PIC 컨트롤러 초기화 및 모든 인터럽트 활성화 kInitializePIC(); kMaskPICInterrupt( 0 ); kEnableInterrupt(); kSetCursor( 45, iCursorY++ ); kPrintf( "Pass\n" ); // 파일 시스템을 초기화 kPrintf("File System Initialize......................[ ]"); if(kInitializeFileSystem()==TRUE) { kSetCursor(45,iCursorY++); kPrintf("Pass\n"); } else { kSetCursor(45,iCursorY++); kPrintf("Fail\n"); } // 시리얼 포트 초기화 kPrintf("Serial Port Initialize......................[Pass]\n"); iCursorY++; kInitializeSerialPort(); // 유후 태스크를 시스템 스레드로 생성하고 셸을 시작 kCreateTask(TASK_FLAGS_LOWEST | TASK_FLAGS_THREAD | TASK_FLAGS_SYSTEM | TASK_FLAGS_IDLE,0,0,(QWORD)kIdleTask,kGetAPICID()); // 그래픽 모드가 아니면 콘솔 셸 실행 if(*(BYTE*)VBE_STARTGRAPHICMODEFLAGADDRESS==0) { kStartConsoleShell(); } // 그래픽 모드면 그래픽 모드 테스트 함수 실행 else { kStartGraphicModeTest(); } }