[util] Move enum_bitfields into util

Continuing on the cleaning up of the src/include 'junk drawer', the
enum_bitfields.h and its dependency basic_types.h are now in util.
This commit is contained in:
Justin C. Miller
2022-01-03 21:42:20 -08:00
parent c1d9b35e7c
commit 411c8c4cb3
13 changed files with 22 additions and 20 deletions

View File

@@ -3,8 +3,8 @@
#include <stddef.h>
#include <stdint.h>
#include <util/enum_bitfields.h>
#include <util/misc.h> // for byteswap32
#include <enum_bitfields.h>
struct acpi_table_header
{

View File

@@ -3,7 +3,7 @@
/// Classes to control both local and I/O APICs.
#include <stdint.h>
#include "enum_bitfields.h"
#include <util/enum_bitfields.h>
enum class isr : uint8_t;

View File

@@ -1,9 +1,9 @@
#pragma once
/// \file gdt.h
/// Definitions relating to a CPU's GDT table
#include <stdint.h>
#include "enum_bitfields.h"
#include <stdint.h>
#include <util/enum_bitfields.h>
class TSS;

View File

@@ -4,7 +4,6 @@
#include <bootproto/kernel.h>
#include <j6/init.h>
#include <util/no_construct.h>
#include <enum_bitfields.h>
#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;

View File

@@ -7,7 +7,7 @@
#include <j6/signals.h>
#include <util/vector.h>
#include <enum_bitfields.h>
#include <util/enum_bitfields.h>
#include "objects/kobject.h"

View File

@@ -4,8 +4,8 @@
#include <stdint.h>
#include <arch/memory.h>
#include <util/enum_bitfields.h>
#include <util/spinlock.h>
#include <enum_bitfields.h>
struct free_page_header;

View File

@@ -4,9 +4,9 @@
#include <stdint.h>
#include <util/enum_bitfields.h>
#include <util/spinlock.h>
#include <util/vector.h>
#include <enum_bitfields.h>
#include "page_table.h"

View File

@@ -6,6 +6,7 @@
#include <stdint.h>
#include <util/counted.h>
#include <util/enum_bitfields.h>
namespace bootproto {
@@ -23,6 +24,7 @@ enum class module_flags : uint8_t {
/// informational purposes only.
no_load = 0x01,
};
is_bitfield(module_flags);
struct module
{

View File

@@ -7,6 +7,7 @@
#include <stdint.h>
#include <util/counted.h>
#include <util/enum_bitfields.h>
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;

View File

@@ -1,6 +1,6 @@
#pragma once
#include <stdint.h>
#include "enum_bitfields.h"
#include <util/enum_bitfields.h>
namespace elf {
@@ -61,6 +61,7 @@ enum class segment_flags : uint32_t
write = 0x02,
read = 0x04,
};
is_bitfield(segment_flags);
struct program_header
{

View File

@@ -1,8 +1,9 @@
#pragma once
#include "basic_types.h"
#include <util/basic_types.h>
namespace bitfields {
namespace util {
namespace bits {
template <typename E>
constexpr bool is_enum_bitfield(E) { return false; }
@@ -81,9 +82,10 @@ constexpr bool has(E set, F flags)
static_cast<typename types::integral<F>::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;

View File

@@ -7,7 +7,7 @@
#include <j6/errors.h>
#include <j6/flags.h>
#include <j6/syscalls.h>
#include <enum_bitfields.h>
#include <util/enum_bitfields.h>
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;