diff --git a/src/kernel/acpi_tables.h b/src/kernel/acpi_tables.h index 383d855..bb98db3 100644 --- a/src/kernel/acpi_tables.h +++ b/src/kernel/acpi_tables.h @@ -3,8 +3,8 @@ #include #include +#include #include // for byteswap32 -#include struct acpi_table_header { diff --git a/src/kernel/apic.h b/src/kernel/apic.h index 912f265..2a25ed2 100644 --- a/src/kernel/apic.h +++ b/src/kernel/apic.h @@ -3,7 +3,7 @@ /// Classes to control both local and I/O APICs. #include -#include "enum_bitfields.h" +#include enum class isr : uint8_t; diff --git a/src/kernel/gdt.h b/src/kernel/gdt.h index e747740..ffce36f 100644 --- a/src/kernel/gdt.h +++ b/src/kernel/gdt.h @@ -1,9 +1,9 @@ #pragma once /// \file gdt.h /// Definitions relating to a CPU's GDT table -#include -#include "enum_bitfields.h" +#include +#include class TSS; diff --git a/src/kernel/memory_bootstrap.cpp b/src/kernel/memory_bootstrap.cpp index 3061f25..3dd7248 100644 --- a/src/kernel/memory_bootstrap.cpp +++ b/src/kernel/memory_bootstrap.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include "assert.h" #include "device_manager.h" @@ -21,10 +20,6 @@ #include "objects/vm_area.h" #include "vm_space.h" -namespace bootproto { - is_bitfield(section_flags); -} - using bootproto::allocation_register; using bootproto::section_flags; diff --git a/src/kernel/objects/vm_area.h b/src/kernel/objects/vm_area.h index 6a22ff2..ae97699 100644 --- a/src/kernel/objects/vm_area.h +++ b/src/kernel/objects/vm_area.h @@ -7,7 +7,7 @@ #include #include -#include +#include #include "objects/kobject.h" diff --git a/src/kernel/page_table.h b/src/kernel/page_table.h index ac0e7c1..c1d63e4 100644 --- a/src/kernel/page_table.h +++ b/src/kernel/page_table.h @@ -4,8 +4,8 @@ #include #include +#include #include -#include struct free_page_header; diff --git a/src/kernel/vm_space.h b/src/kernel/vm_space.h index 7c95812..4b65cfe 100644 --- a/src/kernel/vm_space.h +++ b/src/kernel/vm_space.h @@ -4,9 +4,9 @@ #include +#include #include #include -#include #include "page_table.h" diff --git a/src/libraries/bootproto/include/bootproto/init.h b/src/libraries/bootproto/include/bootproto/init.h index af0dedd..72061f9 100644 --- a/src/libraries/bootproto/include/bootproto/init.h +++ b/src/libraries/bootproto/include/bootproto/init.h @@ -6,6 +6,7 @@ #include #include +#include namespace bootproto { @@ -23,6 +24,7 @@ enum class module_flags : uint8_t { /// informational purposes only. no_load = 0x01, }; +is_bitfield(module_flags); struct module { diff --git a/src/libraries/bootproto/include/bootproto/kernel.h b/src/libraries/bootproto/include/bootproto/kernel.h index 060a8df..3bc79b3 100644 --- a/src/libraries/bootproto/include/bootproto/kernel.h +++ b/src/libraries/bootproto/include/bootproto/kernel.h @@ -7,6 +7,7 @@ #include #include +#include namespace bootproto { @@ -23,6 +24,7 @@ enum class section_flags : uint32_t { write = 2, read = 4, }; +is_bitfield(section_flags); struct program_section { uintptr_t phys_addr; diff --git a/src/libraries/elf/include/elf/headers.h b/src/libraries/elf/include/elf/headers.h index f6c8e82..f5b5402 100644 --- a/src/libraries/elf/include/elf/headers.h +++ b/src/libraries/elf/include/elf/headers.h @@ -1,6 +1,6 @@ #pragma once #include -#include "enum_bitfields.h" +#include namespace elf { @@ -61,6 +61,7 @@ enum class segment_flags : uint32_t write = 0x02, read = 0x04, }; +is_bitfield(segment_flags); struct program_header { diff --git a/src/include/basic_types.h b/src/libraries/util/include/util/basic_types.h similarity index 100% rename from src/include/basic_types.h rename to src/libraries/util/include/util/basic_types.h diff --git a/src/include/enum_bitfields.h b/src/libraries/util/include/util/enum_bitfields.h similarity index 95% rename from src/include/enum_bitfields.h rename to src/libraries/util/include/util/enum_bitfields.h index 29b9050..f4d4784 100644 --- a/src/include/enum_bitfields.h +++ b/src/libraries/util/include/util/enum_bitfields.h @@ -1,8 +1,9 @@ #pragma once -#include "basic_types.h" +#include -namespace bitfields { +namespace util { +namespace bits { template constexpr bool is_enum_bitfield(E) { return false; } @@ -81,9 +82,10 @@ constexpr bool has(E set, F flags) static_cast::type>(flags); } -} // namespace bitfields +} // namespace bits +} // namespace util #define is_bitfield(name) \ constexpr bool is_enum_bitfield(name) { return true; } \ - using namespace ::bitfields; + using namespace ::util::bits; diff --git a/src/user/srv.init/loader.cpp b/src/user/srv.init/loader.cpp index 7a2c8ff..00355b3 100644 --- a/src/user/srv.init/loader.cpp +++ b/src/user/srv.init/loader.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include using bootproto::module_flags; using bootproto::module_program; @@ -22,7 +22,7 @@ constexpr uintptr_t stack_top = 0x80000000000; bool load_program(const module_program &prog, char *err_msg) { - if (bitfields::has(prog.mod_flags, module_flags::no_load)) { + if (prog.mod_flags && module_flags::no_load) { sprintf(err_msg, " skipping pre-loaded program module '%s' at %lx", prog.filename, prog.base_address); return true; } @@ -64,7 +64,7 @@ load_program(const module_program &prog, char *err_msg) // TODO: way to remap VMA as read-only if there's no write flag on // the segment unsigned long flags = j6_vm_flag_write; - if (bitfields::has(seg.flags, elf::segment_flags::exec)) + if (seg.flags && elf::segment_flags::exec) flags |= j6_vm_flag_exec; j6_handle_t sub_vma = j6_handle_invalid;