From: Daniel R. <co...@us...> - 2006-10-19 17:49:29
|
Update of /cvsroot/trion/trion v0.2/loader In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv12036 Added Files: multiboot.cpp multiboot.hpp Log Message: no message --- NEW FILE: multiboot.hpp --- // ----------------------------------------------------------------------- // multiboot.hpp - Parser class for the multiboot-table created by GRUB // // Author(s) : // Date : MM/DD/2006 // Version : 0.2.0 // Home Page : http://trion.sourceforge.net // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- // Copyright (C) 2006, Trion Development Group Members // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the Trion Development Group nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ----------------------------------------------------------------------- #ifndef __LOADER__MULTIBOOT_HPP__ #define __LOADER__MULTIBOOT_HPP__ #include <std_types.hpp> struct multiboot_info { struct present_flags { bool memory_amount : 1; bool boot_device : 1; bool command_line : 1; bool module_table : 1; bool elf_headers : 1; bool memory_table : 1; bool drive_table : 1; bool config_table : 1; bool loader_name : 1; bool apm_table : 1; bool vbe_info : 1; u32b : 21; } flags; u32b memory_lower; u32b memory_upper; u32b boot_device; char* command_line; u32b number_modules; void* modules_address; struct elf { u32b number_entries; u32b size_entry; void* section_table; void* string_table; }; u32b memory_map_length; void* memory_map_address; u32b drives_length; void* drives_address; void* config_table; char* loader_name; void* apm_table; struct vbe { void* control_info; void* mode_info; u32b mode_number; u32b interface_segment; u32b interface_offset; u32b interface_length; }; }; struct module_entry { u32b module_start; u32b module_end; char* string; u32b reserved; }; struct memory_entry { u32b size; u32b base_address_low; u32b base_address_high; u32b length_low; u32b length_high; u32b type; }; struct range { private: u32b base_address; u32b length; public: range(u32b base, u32b size) : base_address(base), length(size){} u32b BaseAddress() { return base_address; } u32b Length() { return length; } }; class multiboot_detect { private: multiboot_info* table; vRange* table_window; // Both functions return physical addresses u32b GetFirstModule(); u32b GetFirstMemory(); u32b GetNextMemory(memory_entry* current); // Returns an offset public: multiboot_detect(u32b magic, u32b multiboot_table); // Memory Interface u32b GetTotalAmountMemory(); range GetMemoryChunk(u32 minimum_size); // Module Interface u16b GetNumberModules(); range GetModuleAddress(u16b number); }; multiboot_detect& InitializeMultiboot(u32b magic, u32b table); multiboot_detect& multiboot(); #endif --- NEW FILE: multiboot.cpp --- // ----------------------------------------------------------------------- // multiboot.cpp - Parser class for the multiboot-table created by GRUB // // Author(s) : // Date : MM/DD/2006 // Version : 0.2.0 // Home Page : http://trion.sourceforge.net // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- // Copyright (C) 2006, Trion Development Group Members // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the Trion Development Group nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ----------------------------------------------------------------------- #include <multiboot.hpp> #include <heap_manager.hpp> #include <console.hpp> |