mirror of https://github.com/tailix/libkernaux.git
Add i386 stuff (#116)
* Add struct KernAux_Arch_I386_IDTE * Add struct KernAux_Arch_I386_DTR * Remove unnecessary static check * Add func KernAux_Arch_I386_IDTE_set_offset
This commit is contained in:
parent
91bce08aa3
commit
971b2f4803
|
@ -126,6 +126,7 @@
|
||||||
/tests/multiboot2_header_print2
|
/tests/multiboot2_header_print2
|
||||||
/tests/multiboot2_info_print1
|
/tests/multiboot2_info_print1
|
||||||
/tests/multiboot2_info_print2
|
/tests/multiboot2_info_print2
|
||||||
|
/tests/test_arch_i386
|
||||||
/tests/test_cmdline
|
/tests/test_cmdline
|
||||||
/tests/test_cmdline_gen
|
/tests/test_cmdline_gen
|
||||||
/tests/test_cmdline_gen.c
|
/tests/test_cmdline_gen.c
|
||||||
|
|
|
@ -53,6 +53,16 @@ extern "C" {
|
||||||
|
|
||||||
#include <kernaux/macro/packing_start.run>
|
#include <kernaux/macro/packing_start.run>
|
||||||
|
|
||||||
|
// Global, local or interrupt descriptor table register
|
||||||
|
// TODO: validate this according to spec
|
||||||
|
struct KernAux_Arch_I386_DTR {
|
||||||
|
uint16_t size;
|
||||||
|
uint32_t offset;
|
||||||
|
}
|
||||||
|
KERNAUX_PACKING_ATTR;
|
||||||
|
|
||||||
|
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_DTR, 6);
|
||||||
|
|
||||||
// Global or local descriptor table entry
|
// Global or local descriptor table entry
|
||||||
// TODO: validate this according to spec
|
// TODO: validate this according to spec
|
||||||
struct KernAux_Arch_I386_DTE {
|
struct KernAux_Arch_I386_DTE {
|
||||||
|
@ -74,8 +84,25 @@ struct KernAux_Arch_I386_DTE {
|
||||||
}
|
}
|
||||||
KERNAUX_PACKING_ATTR;
|
KERNAUX_PACKING_ATTR;
|
||||||
|
|
||||||
|
// Interrupt descriptor table entry
|
||||||
|
// TODO: validate this according to spec
|
||||||
|
typedef struct KernAux_Arch_I386_IDTE {
|
||||||
|
uint16_t offset_low;
|
||||||
|
uint16_t selector;
|
||||||
|
uint8_t _zero0;
|
||||||
|
uint8_t flags;
|
||||||
|
uint16_t offset_high;
|
||||||
|
}
|
||||||
|
KERNAUX_PACKING_ATTR
|
||||||
|
*KernAux_Arch_I386_IDTE;
|
||||||
|
|
||||||
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_DTE, 8);
|
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_Arch_I386_DTE, 8);
|
||||||
|
|
||||||
|
void KernAux_Arch_I386_IDTE_set_offset(
|
||||||
|
KernAux_Arch_I386_IDTE idte,
|
||||||
|
uint32_t address
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Task state segment
|
* @brief Task state segment
|
||||||
* @see The manual, page 132, figure 7-1
|
* @see The manual, page 132, figure 7-1
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
#include <kernaux/arch/i386.h>
|
#include <kernaux/arch/i386.h>
|
||||||
|
|
||||||
__attribute__((unused))
|
void KernAux_Arch_I386_IDTE_set_offset(
|
||||||
static const int
|
const KernAux_Arch_I386_IDTE idte,
|
||||||
TSS_validation[sizeof(struct KernAux_Arch_I386_TSS) == 104 ? 1 : -1];
|
const uint32_t address
|
||||||
|
)
|
||||||
|
{
|
||||||
|
idte->offset_low = 0xFFFF & address;
|
||||||
|
idte->offset_high = 0xFFFF & (address >> 16);
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,18 @@ multiboot2_info_print2_SOURCES = \
|
||||||
multiboot2_info_example2.h
|
multiboot2_info_example2.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
##################
|
||||||
|
# test_arch_i386 #
|
||||||
|
##################
|
||||||
|
|
||||||
|
if WITH_ARCH_I386
|
||||||
|
TESTS += test_arch_i386
|
||||||
|
test_arch_i386_LDADD = $(top_builddir)/libkernaux.la
|
||||||
|
test_arch_i386_SOURCES = \
|
||||||
|
main.c \
|
||||||
|
test_arch_i386.c
|
||||||
|
endif
|
||||||
|
|
||||||
################
|
################
|
||||||
# test_cmdline #
|
# test_cmdline #
|
||||||
################
|
################
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <kernaux/arch/i386.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static void test_idte_set_offset();
|
||||||
|
|
||||||
|
void test_main()
|
||||||
|
{
|
||||||
|
test_idte_set_offset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_idte_set_offset()
|
||||||
|
{
|
||||||
|
struct KernAux_Arch_I386_IDTE idte;
|
||||||
|
memset(&idte, 0, sizeof(idte));
|
||||||
|
|
||||||
|
KernAux_Arch_I386_IDTE_set_offset(&idte, 0);
|
||||||
|
assert(idte.offset_high == 0);
|
||||||
|
assert(idte.offset_low == 0);
|
||||||
|
|
||||||
|
KernAux_Arch_I386_IDTE_set_offset(&idte, 0xFFFFFFFF);
|
||||||
|
assert(idte.offset_high == 0xFFFF);
|
||||||
|
assert(idte.offset_low == 0xFFFF);
|
||||||
|
|
||||||
|
KernAux_Arch_I386_IDTE_set_offset(&idte, 0x12345678);
|
||||||
|
assert(idte.offset_high == 0x1234);
|
||||||
|
assert(idte.offset_low == 0x5678);
|
||||||
|
}
|
Loading…
Reference in New Issue