Compare commits
3 Commits
232b19666a
...
cc9aca2595
Author | SHA1 | Date | |
---|---|---|---|
cc9aca2595 | |||
07ff7f6087 | |||
8958b87f65 |
@ -8,3 +8,4 @@ int strncmp(const char *s1, const char *s2, size_t n);
|
|||||||
size_t strlen(const char *str);
|
size_t strlen(const char *str);
|
||||||
char *strstr(const char *haystack, const char *needle);
|
char *strstr(const char *haystack, const char *needle);
|
||||||
void *memcpy(void *dest, const void *src, size_t n);
|
void *memcpy(void *dest, const void *src, size_t n);
|
||||||
|
int memcmp(const void *s1, const void *s2, size_t n);
|
@ -13,3 +13,15 @@ static inline uint8_t inb(uint16_t port)
|
|||||||
__asm__ volatile("inb %w1, %b0" : "=a"(ret) : "Nd"(port) : "memory");
|
__asm__ volatile("inb %w1, %b0" : "=a"(ret) : "Nd"(port) : "memory");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void outw(uint16_t port, uint16_t val)
|
||||||
|
{
|
||||||
|
__asm__ volatile("outb %b0, %w1" : : "a"(val), "Nd"(port) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint16_t inw(uint16_t port)
|
||||||
|
{
|
||||||
|
uint8_t ret;
|
||||||
|
__asm__ volatile("inb %w1, %b0" : "=a"(ret) : "Nd"(port) : "memory");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
13
libbozo/src/string/memcmp.c
Normal file
13
libbozo/src/string/memcmp.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
int memcmp(const void *s1, const void *s2, size_t n)
|
||||||
|
{
|
||||||
|
const char *str1 = s1;
|
||||||
|
const char *str2 = s2;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
return 0;
|
||||||
|
for (i = 0; str1[i] == str2[i] && i < n - 1; i++);
|
||||||
|
return str1[i] - str2[i];
|
||||||
|
}
|
@ -50,9 +50,11 @@ void initGdt()
|
|||||||
.base = 0, .limit = 0xFFFFF, .access_byte = 0x92, .flags = 0xC};
|
.base = 0, .limit = 0xFFFFF, .access_byte = 0x92, .flags = 0xC};
|
||||||
encodeGdtEntry(gdt_entries[2], gdt_entry_kernel_mode_data_segment);
|
encodeGdtEntry(gdt_entries[2], gdt_entry_kernel_mode_data_segment);
|
||||||
|
|
||||||
struct gdt_entry gdt_entry_kernel_mode_stack_segment = {
|
struct gdt_entry gdt_entry_kernel_mode_stack_segment = { .base = 0x0,
|
||||||
.base = 0x0, .limit = 0x0, .access_byte = 0x97, .flags = 0x0D};
|
.limit = 0x0,
|
||||||
encodeGdtEntry(gdt_entries[3], gdt_entry_kernel_mode_data_segment);
|
.access_byte = 0x97,
|
||||||
|
.flags = 0x0D };
|
||||||
|
encodeGdtEntry(gdt_entries[3], gdt_entry_kernel_mode_stack_segment);
|
||||||
|
|
||||||
struct gdt_entry gdt_entry_user_mode_code_segment = {
|
struct gdt_entry gdt_entry_user_mode_code_segment = {
|
||||||
.base = 0, .limit = 0xFFFFF, .access_byte = 0xFA, .flags = 0xC};
|
.base = 0, .limit = 0xFFFFF, .access_byte = 0xFA, .flags = 0xC};
|
||||||
@ -62,9 +64,11 @@ void initGdt()
|
|||||||
.base = 0, .limit = 0xFFFFF, .access_byte = 0xF2, .flags = 0xC};
|
.base = 0, .limit = 0xFFFFF, .access_byte = 0xF2, .flags = 0xC};
|
||||||
encodeGdtEntry(gdt_entries[5], gdt_entry_user_mode_data_segment);
|
encodeGdtEntry(gdt_entries[5], gdt_entry_user_mode_data_segment);
|
||||||
|
|
||||||
struct gdt_entry gdt_entry_user_mode_stack_segment = {
|
struct gdt_entry gdt_entry_user_mode_stack_segment = { .base = 0x0,
|
||||||
.base = 0x0, .limit = 0x0, .access_byte = 0xF7, .flags = 0x0D};
|
.limit = 0x0,
|
||||||
encodeGdtEntry(gdt_entries[6], gdt_entry_user_mode_data_segment);
|
.access_byte = 0xF7,
|
||||||
|
.flags = 0x0D };
|
||||||
|
encodeGdtEntry(gdt_entries[6], gdt_entry_user_mode_stack_segment);
|
||||||
|
|
||||||
memcpy((void *)gdtr.base, (void *)gdt_entries, (size_t)GDT_SIZE);
|
memcpy((void *)gdtr.base, (void *)gdt_entries, (size_t)GDT_SIZE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user