📄 multiboot.c
字号:
/** multiboot.c ** ** Original Author: Kasper Verdich Lund ** Date: 10.26.99 ** ** Description: ** Routines for handling the multiboot information ** ** 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 <multiboot.h>#include <halt.h>#include <string.h>#include <mem.h>#ifdef DEBUG#include <debug/conio.h>#endifdword AvailableMemory(multibootInfo *bootInfo){ if (bootInfo->flags & MULTIBOOT_MEMORY) { return ((bootInfo->memoryUpper + 1024) << 10); } else { /* this shouldn't happen - the bootloader has * to provide information on available memory */#ifdef DEBUG DebugPrintF("No memory information!\n");#endif halt(); }}dword UsedMemory(multibootInfo *bootInfo){ int i; extern void end; dword top = (dword)&end; if (bootInfo->flags & MULTIBOOT_MODS) { for (i=0; i<bootInfo->modulesCount; i++) if (bootInfo->modules[i].end > top) top = bootInfo->modules[i].end; } top = (top + 4095) & 0xFFFFF000; return top;}multibootInfo *CopyMultibootInfo(multibootInfo *bootInfo){ multibootInfo *newInfo; newInfo = malloc(sizeof(multibootInfo)); memcpy(newInfo,bootInfo,sizeof(multibootInfo)); newInfo->commandLine = malloc(strlen(bootInfo->commandLine)+1); strcpy(newInfo->commandLine,bootInfo->commandLine); if (newInfo->flags & MULTIBOOT_MODS) { int i; newInfo->modules = malloc(sizeof(multibootModule)*newInfo->modulesCount); memcpy(newInfo->modules,bootInfo->modules,sizeof(multibootModule)*newInfo->modulesCount); for (i=0;i<newInfo->modulesCount;i++) { newInfo->modules[i].string = malloc(strlen(bootInfo->modules[i].string)+1); strcpy(newInfo->modules[i].string,bootInfo->modules[i].string); } } return newInfo;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -