⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 一个操作系统的源代码
💻 C
字号:
/** main.c                                   **                                                               ** Original Author: Kasper Verdich Lund                          ** Date: 10.26.99      **  ** Description: ** Main file for the microkernel      **                                        ** Revision History:  ** First version      ** ** 0.0.1 10.26.99 Kasper Verdich Lund - (no comments) ** ** This program is free software, you can redistribute it and/or ** modify it under the terms of the GNU General Public License   ** as published by the Free Software Foundation; either version  ** 2 of the License, or (at your option) any later version.      **                                                               ** This program is distributed in the hope that it will be       ** useful, but WITHOUT ANY WARRANTY; without even the implied    ** warranty or MERCHANTABILITY or FITNESS FOR A PARTICULAR       ** PURPOSE.  See the GNU General Public License for more        ** details.                                                      **                                                               ** You should have received a copy of the GNU General Public     ** License along with this program; if not, write to the         ** Free Software Foundation, Inc., 59 Temple Place, Suite 330,   ** Boston, MA 02111-1307 USA                                     **                                                               *********************************************************Apostle OS**/#include <types.h>#include <mem.h>#include <string.h>#include <gdt.h>#include <idt.h>#include <pic.h>#include <tss.h>#include <multiboot.h>#include <paging.h>#include <exception.h>#include <service.h>#include <process.h>#include <scheduler.h>#include <address_space.h>#include <halt.h>#ifdef DEBUG#include <debug/conio.h>#endifmultibootInfo *bootInfo;int main(multibootInfo *volatile_bootInfo){  dword availableMemory;#ifdef DEBUG  DebugConsoleInit(COL_BLACK, COL_GRAY);  DebugPrintF("Apostle microkernel 0.0.3\n");#endif  /* setup allocation routines for   * allocation of physical pages */  availableMemory = AvailableMemory(volatile_bootInfo);  psetup(availableMemory, UsedMemory(volatile_bootInfo));  setupPaging(availableMemory);  enablePaging();  /* malloc, calloc and free are now available */  bootInfo = CopyMultibootInfo(volatile_bootInfo);  reprogramPIC();  setupGDT();  setupIDT();  setupTSS();  setupExceptions();  setupServices();  setupScheduler();#ifdef DEBUG  DebugPrintF("Kernel setup complete\n");#endif  if (bootInfo->flags & MULTIBOOT_MODS)    {      int i;      for(i = 0; i < bootInfo->modulesCount; i++)        {	  Process *mp = NewProcess();#ifdef DEBUG          DebugPrintF("Module %d: %s\n", i, bootInfo->modules[i].string);#endif	  map(systemSpace, (void *)bootInfo->modules[i].start, \		mp->addressSpace, (void *)0x20000000, \		(bootInfo->modules[i].end - bootInfo->modules[i].start + \		 PAGE_SIZE - 1) >> 12,                PAGE_USER | PAGE_WRITABLE | PAGE_PRESENT);	  InsertProcess(&readyQueue, mp, FALSE);	}    }  else    {#ifdef DEBUG      DebugPrintF("No modules loaded\n");#endif      halt();    }  /* we now have a collection of processes    * in the readyQueue - setup scheduler to run them */  Reallocate();    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -