[bootproto] Create new bootproto lib
This is a rather large commit that is widely focused on cleaning things out of the 'junk drawer' that is src/include. Most notably, several things that were put in there because they needed somewhere where both the kernel, boot, and init could read them have been moved to a new lib, 'bootproto'. - Moved kernel_args.h and init_args.h to bootproto as kernel.h and init.h, respectively. - Moved counted.h and pointer_manipulation.h into util, renaming the latter to util/pointers.h. - Created a new src/include/arch for very arch-dependent definitions, and moved some kernel_memory.h constants like frame size, page table entry count, etc to arch/amd64/memory.h. Also created arch/memory.h which detects platform and includes the former. - Got rid of kernel_memory.h entirely in favor of a new, cog-based approach. The new definitions/memory_layout.csv lists memory regions in descending order from the top of memory, their sizes, and whether they are shared outside the kernel (ie, boot needs to know them). The new header bootproto/memory.h exposes the addresses of the shared regions, while the kernel's memory.h gains the start and size of all the regions. Also renamed the badly-named page-offset area the linear area. - The python build scripts got a few new features: the ability to parse the csv mentioned above in a new memory.py module; the ability to add dependencies to existing source files (The list of files that I had to pull out of the main list just to add them with the dependency on memory.h was getting too large. So I put them back into the sources list, and added the dependency post-hoc.); and the ability to reference 'source_root', 'build_root', and 'module_root' variables in .module files. - Some utility functions that were in the kernel's memory.h got moved to util/pointers.h and util/misc.h, and misc.h's byteswap was renamed byteswap32 to be more specific.
This commit is contained in:
@@ -2,20 +2,19 @@
|
||||
/// \file memory_map.h
|
||||
/// Memory-map related types and functions
|
||||
|
||||
#include "counted.h"
|
||||
#include "pointer_manipulation.h"
|
||||
#include <util/counted.h>
|
||||
#include <util/pointers.h>
|
||||
|
||||
namespace uefi {
|
||||
struct boot_services;
|
||||
struct memory_descriptor;
|
||||
}
|
||||
|
||||
namespace kernel {
|
||||
namespace init {
|
||||
namespace bootproto {
|
||||
struct args;
|
||||
struct frame_block;
|
||||
struct mem_entry;
|
||||
}}
|
||||
}
|
||||
|
||||
namespace boot {
|
||||
namespace memory {
|
||||
@@ -25,7 +24,7 @@ namespace memory {
|
||||
struct efi_mem_map
|
||||
{
|
||||
using desc = uefi::memory_descriptor;
|
||||
using iterator = offset_iterator<desc>;
|
||||
using iterator = util::offset_iterator<desc>;
|
||||
|
||||
size_t length; ///< Total length of the map data
|
||||
size_t total; ///< Total allocated space for map data
|
||||
@@ -46,18 +45,18 @@ struct efi_mem_map
|
||||
inline iterator begin() { return iterator(entries, size); }
|
||||
|
||||
/// Return an iterator to the end of the array
|
||||
inline iterator end() { return offset_ptr<desc>(entries, length); }
|
||||
inline iterator end() { return util::offset_pointer(entries, length); }
|
||||
};
|
||||
|
||||
/// Add the kernel's memory map as a module to the kernel args.
|
||||
/// \returns The uefi memory map used to build the kernel map
|
||||
counted<kernel::init::mem_entry> build_kernel_map(efi_mem_map &map);
|
||||
util::counted<bootproto::mem_entry> build_kernel_map(efi_mem_map &map);
|
||||
|
||||
/// Create the kernel frame allocation maps
|
||||
counted<kernel::init::frame_block> build_frame_blocks(const counted<kernel::init::mem_entry> &kmap);
|
||||
util::counted<bootproto::frame_block> build_frame_blocks(const util::counted<bootproto::mem_entry> &kmap);
|
||||
|
||||
/// Map the frame allocation maps to the right spot and fix up pointers
|
||||
void fix_frame_blocks(kernel::init::args *args);
|
||||
void fix_frame_blocks(bootproto::args *args);
|
||||
|
||||
} // namespace boot
|
||||
} // namespace memory
|
||||
|
||||
Reference in New Issue
Block a user