mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[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:
@@ -3,8 +3,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <util/enum_bitfields.h>
|
||||||
#include <util/misc.h> // for byteswap32
|
#include <util/misc.h> // for byteswap32
|
||||||
#include <enum_bitfields.h>
|
|
||||||
|
|
||||||
struct acpi_table_header
|
struct acpi_table_header
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
/// Classes to control both local and I/O APICs.
|
/// Classes to control both local and I/O APICs.
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "enum_bitfields.h"
|
#include <util/enum_bitfields.h>
|
||||||
|
|
||||||
enum class isr : uint8_t;
|
enum class isr : uint8_t;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
/// \file gdt.h
|
/// \file gdt.h
|
||||||
/// Definitions relating to a CPU's GDT table
|
/// 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;
|
class TSS;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <bootproto/kernel.h>
|
#include <bootproto/kernel.h>
|
||||||
#include <j6/init.h>
|
#include <j6/init.h>
|
||||||
#include <util/no_construct.h>
|
#include <util/no_construct.h>
|
||||||
#include <enum_bitfields.h>
|
|
||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "device_manager.h"
|
#include "device_manager.h"
|
||||||
@@ -21,10 +20,6 @@
|
|||||||
#include "objects/vm_area.h"
|
#include "objects/vm_area.h"
|
||||||
#include "vm_space.h"
|
#include "vm_space.h"
|
||||||
|
|
||||||
namespace bootproto {
|
|
||||||
is_bitfield(section_flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
using bootproto::allocation_register;
|
using bootproto::allocation_register;
|
||||||
using bootproto::section_flags;
|
using bootproto::section_flags;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <j6/signals.h>
|
#include <j6/signals.h>
|
||||||
#include <util/vector.h>
|
#include <util/vector.h>
|
||||||
#include <enum_bitfields.h>
|
#include <util/enum_bitfields.h>
|
||||||
|
|
||||||
#include "objects/kobject.h"
|
#include "objects/kobject.h"
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <arch/memory.h>
|
#include <arch/memory.h>
|
||||||
|
#include <util/enum_bitfields.h>
|
||||||
#include <util/spinlock.h>
|
#include <util/spinlock.h>
|
||||||
#include <enum_bitfields.h>
|
|
||||||
|
|
||||||
struct free_page_header;
|
struct free_page_header;
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <util/enum_bitfields.h>
|
||||||
#include <util/spinlock.h>
|
#include <util/spinlock.h>
|
||||||
#include <util/vector.h>
|
#include <util/vector.h>
|
||||||
#include <enum_bitfields.h>
|
|
||||||
|
|
||||||
#include "page_table.h"
|
#include "page_table.h"
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <util/counted.h>
|
#include <util/counted.h>
|
||||||
|
#include <util/enum_bitfields.h>
|
||||||
|
|
||||||
namespace bootproto {
|
namespace bootproto {
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ enum class module_flags : uint8_t {
|
|||||||
/// informational purposes only.
|
/// informational purposes only.
|
||||||
no_load = 0x01,
|
no_load = 0x01,
|
||||||
};
|
};
|
||||||
|
is_bitfield(module_flags);
|
||||||
|
|
||||||
struct module
|
struct module
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <util/counted.h>
|
#include <util/counted.h>
|
||||||
|
#include <util/enum_bitfields.h>
|
||||||
|
|
||||||
namespace bootproto {
|
namespace bootproto {
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ enum class section_flags : uint32_t {
|
|||||||
write = 2,
|
write = 2,
|
||||||
read = 4,
|
read = 4,
|
||||||
};
|
};
|
||||||
|
is_bitfield(section_flags);
|
||||||
|
|
||||||
struct program_section {
|
struct program_section {
|
||||||
uintptr_t phys_addr;
|
uintptr_t phys_addr;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "enum_bitfields.h"
|
#include <util/enum_bitfields.h>
|
||||||
|
|
||||||
namespace elf {
|
namespace elf {
|
||||||
|
|
||||||
@@ -61,6 +61,7 @@ enum class segment_flags : uint32_t
|
|||||||
write = 0x02,
|
write = 0x02,
|
||||||
read = 0x04,
|
read = 0x04,
|
||||||
};
|
};
|
||||||
|
is_bitfield(segment_flags);
|
||||||
|
|
||||||
struct program_header
|
struct program_header
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "basic_types.h"
|
#include <util/basic_types.h>
|
||||||
|
|
||||||
namespace bitfields {
|
namespace util {
|
||||||
|
namespace bits {
|
||||||
|
|
||||||
template <typename E>
|
template <typename E>
|
||||||
constexpr bool is_enum_bitfield(E) { return false; }
|
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);
|
static_cast<typename types::integral<F>::type>(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace bitfields
|
} // namespace bits
|
||||||
|
} // namespace util
|
||||||
|
|
||||||
#define is_bitfield(name) \
|
#define is_bitfield(name) \
|
||||||
constexpr bool is_enum_bitfield(name) { return true; } \
|
constexpr bool is_enum_bitfield(name) { return true; } \
|
||||||
using namespace ::bitfields;
|
using namespace ::util::bits;
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <j6/errors.h>
|
#include <j6/errors.h>
|
||||||
#include <j6/flags.h>
|
#include <j6/flags.h>
|
||||||
#include <j6/syscalls.h>
|
#include <j6/syscalls.h>
|
||||||
#include <enum_bitfields.h>
|
#include <util/enum_bitfields.h>
|
||||||
|
|
||||||
using bootproto::module_flags;
|
using bootproto::module_flags;
|
||||||
using bootproto::module_program;
|
using bootproto::module_program;
|
||||||
@@ -22,7 +22,7 @@ constexpr uintptr_t stack_top = 0x80000000000;
|
|||||||
bool
|
bool
|
||||||
load_program(const module_program &prog, char *err_msg)
|
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);
|
sprintf(err_msg, " skipping pre-loaded program module '%s' at %lx", prog.filename, prog.base_address);
|
||||||
return true;
|
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
|
// TODO: way to remap VMA as read-only if there's no write flag on
|
||||||
// the segment
|
// the segment
|
||||||
unsigned long flags = j6_vm_flag_write;
|
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;
|
flags |= j6_vm_flag_exec;
|
||||||
|
|
||||||
j6_handle_t sub_vma = j6_handle_invalid;
|
j6_handle_t sub_vma = j6_handle_invalid;
|
||||||
|
|||||||
Reference in New Issue
Block a user