20 uint32_t *ret_value = (uint32_t *)
memcpy((
void *) (&dest), (
const void *) (&src), 8);
22 if ((uint64_t) ret_value == (uint64_t) &dest && *ret_value == src)
30 uint32_t *ret_value = (uint32_t *)
memmove((
void *) (&dest), (
const void *) (&src), 8);
32 if ((uint64_t) ret_value == (uint64_t) &dest && *ret_value == src)
40 uint8_t *ret_value = (uint8_t *)
memset((
void *) (&dest), value, 8);
42 unsigned char small_value = (
unsigned char) value;
44 if (ret_value[0] == small_value &&
45 ret_value[1] == small_value &&
46 ret_value[2] == small_value &&
47 ret_value[3] == small_value &&
48 ret_value[4] == small_value &&
49 ret_value[5] == small_value &&
50 ret_value[6] == small_value &&
51 ret_value[7] == small_value)
59 int ret_value = (int)
memcmp((
void *) (&a), (
void *) (&b), 8);
61 if (ret_value == expected_value)
68 if (
strlen(str) == expected_value)
95 kprintf(
"%d (-2147483648)\n", -2147483648);
96 kprintf(
"%d (2147483647)\n", 2147483647);
97 kprintf(
"%u (4294967295)\n", 4294967295u);
101 kprintf(
"%lu (18446744073709551615)\n", 18446744073709551615UL);
102 kprintf(
"%ld (-9223372036854775808)\n", LONG_MIN);
103 kprintf(
"%lx (ffffffff80001000)\n", 0xFFFFFFFF80001000UL);
104 kprintf(
"%p (0xffffffff80001000)\n\n", (
void *) 0xFFFFFFFF80001000UL);
105 kprintf(
"%c%c%c (ABC)\n",
'A',
'B',
'C');
106 kprintf(
"%s|%s (a|)\n",
"a",
"");
108 kprintf(
"%s ((null))\n", (
char *) 0);
115 volatile int zero = 0;
116 asm volatile (
"idiv %0, %1" :
"=r"(zero),
"=r"(zero) : :
"memory");
120 int x = *(
volatile int *) 0xdead0000;
124 uintptr_t addr = 0x10;
125 __asm__
volatile (
"movl %1, (%0)"
127 :
"r" (addr),
"r" (10)
132 asm volatile (
"int3");
uint8_t get_access_byte(bool rw, bool exec, bool type, uint8_t dpl)
Generates the access byte for the GDT.
uint8_t get_flag_byte(bool granularity, bool size, bool long_mode)
Generates the flag byte for the GDT.
Initializes and holds the GDT for the kernel.
Tools for printing to the console and serial output.
void kprintf(const char *fmt,...) __attribute__((format(printf
Wrapper for a standard print.
Utilities for memory and string operations.
size_t strlen(const char *str)
Calculates the length of a string.
void * memset(void *dest, int c, size_t n)
Fills n bytes of the destination with c.
void * memmove(void *dest, const void *src, size_t n)
Copies memory from one address to the other with possible overlap.
int memcmp(const void *a, const void *b, size_t n)
Compares 2 the value of 2 memory addresses.
void * memcpy(void *dest, const void *src, size_t n)
Copies memory from one address to the other without overlapping.
bool test_memcmp(uint64_t a, uint64_t b, int expected_value)
Tests the memcmp utility.
void test_pf_write_fault(void)
Causes a Page fault (write) for handler testing.
bool test_memmove(uint64_t dest, uint64_t src)
Tests the memmove utility.
void test_pf_read_fault(void)
Causes a Page fault (read) for handler testing.
bool test_flag_byte(void)
Tests the flag byte utility for the gdt.
bool test_memset(uint64_t dest, int value)
Tests the memset utility.
void test_bp_fault(void)
Triggers a Breakpoint for handler testing.
bool test_strlen(const char *str, uint8_t expected_value)
Tests the strlen utility.
void test_de_fault(void)
Causes a Division error for handler testing.
void test_kprintf_values(void)
Prints test data and the expected values for visual verification of kprintf.
bool test_access_byte(void)
Tests the access byte utility for the gdt.
bool test_memcpy(uint64_t dest, uint64_t src)
Tests the memcpy utility.
Tools for testing different parts of the kernel.