[refactor] Organize STRING
This commit is contained in:
+4
-14
@@ -1,7 +1,7 @@
|
||||
#include <fs.h>
|
||||
#include <serial.h>
|
||||
#include <memory/heap.h>
|
||||
#include <common.h>
|
||||
#include <string_utils.h>
|
||||
|
||||
extern EFI_SYSTEM_TABLE *ST;
|
||||
|
||||
@@ -537,14 +537,7 @@ struct list_ctx {
|
||||
};
|
||||
|
||||
static void name_to_ascii(const CHAR16 *Name, char *Ascii, UINTN ascii_sz) {
|
||||
UINTN i = 0;
|
||||
for (; Name[i] && i < ascii_sz - 1; i++) {
|
||||
if (Name[i] >= 0x20 && Name[i] <= 0x7E)
|
||||
Ascii[i] = (char)Name[i];
|
||||
else
|
||||
Ascii[i] = '?';
|
||||
}
|
||||
Ascii[i] = 0;
|
||||
wstr_to_ascii(Ascii, (WString)Name, ascii_sz);
|
||||
}
|
||||
|
||||
static void list_callback(void *ctx, const CHAR16 *Name, UINT8 Attr,
|
||||
@@ -633,10 +626,7 @@ struct find_ctx {
|
||||
};
|
||||
|
||||
static BOOLEAN name_match(const CHAR16 *a, const CHAR16 *b) {
|
||||
UINTN i = 0;
|
||||
for (; a[i] && b[i]; i++)
|
||||
if (a[i] != b[i]) return FALSE;
|
||||
return a[i] == 0 && b[i] == 0;
|
||||
return wstr_eq((WString)a, (WString)b);
|
||||
}
|
||||
|
||||
static void find_callback(void *ctx, const CHAR16 *Name, UINT8 Attr,
|
||||
@@ -651,7 +641,7 @@ static void find_callback(void *ctx, const CHAR16 *Name, UINT8 Attr,
|
||||
}
|
||||
}
|
||||
|
||||
EFI_STATUS fs_read(const CHAR16 *Path, void **Buffer, UINTN *Size) {
|
||||
EFI_STATUS fs_read(WString Path, void **Buffer, UINTN *Size) {
|
||||
if (!g_fs_inited) return EFI_NOT_READY;
|
||||
|
||||
const CHAR16 *p = Path;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <serial.h>
|
||||
#include <idt.h>
|
||||
#include <pic.h>
|
||||
#include <common.h>
|
||||
#include <string_utils.h>
|
||||
|
||||
// --- Layer list (sorted by z, lowest first) ---
|
||||
|
||||
@@ -84,12 +84,7 @@ layer_t* layer_create(const char* name, layer_type_t type, UINT32 w, UINT32 h) {
|
||||
layer->visible = true;
|
||||
layer->next = NULL;
|
||||
|
||||
const char* s = name;
|
||||
char* d = layer->name;
|
||||
for (SSINT32 i = 0; i < LAYER_NAME_LEN - 1 && *s; i++) {
|
||||
*d++ = *s++;
|
||||
}
|
||||
*d = '\0';
|
||||
str_copy(layer->name, name, LAYER_NAME_LEN);
|
||||
|
||||
UINTN buf_size = (UINTN)w * h * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||
layer->buffer = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL*)kmalloc(buf_size);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <gdt.h>
|
||||
#include <common.h>
|
||||
#include <string_utils.h>
|
||||
#include <serial.h>
|
||||
|
||||
static gdt_entry g_gdt[7]; // 5 segments + TSS (2 entries)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <idt.h>
|
||||
#include <common.h>
|
||||
#include <string_utils.h>
|
||||
#include <pic.h>
|
||||
#include <serial.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <pic.h>
|
||||
#include <common.h>
|
||||
#include <string_utils.h>
|
||||
#include <serial.h>
|
||||
|
||||
static inline void outb(UINT16 port, UINT8 val) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <pit.h>
|
||||
#include <common.h>
|
||||
#include <string_utils.h>
|
||||
#include <pic.h>
|
||||
#include <serial.h>
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <fonts/pixel_font.h>
|
||||
#include <serial.h>
|
||||
#include <common.h>
|
||||
#include <string_utils.h>
|
||||
#include <memory/pmm.h>
|
||||
#include <memory/heap.h>
|
||||
#include <scheduler.h>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <memory/heap.h>
|
||||
#include <memory/pmm.h>
|
||||
#include <serial.h>
|
||||
#include <string_utils.h>
|
||||
|
||||
struct heap_block {
|
||||
UINTN size; // includes header; bit 0 = 1 used, 0 free
|
||||
@@ -184,10 +185,7 @@ void* kcalloc(UINTN num, UINTN size) {
|
||||
UINTN total = num * size;
|
||||
void* ptr = kmalloc(total);
|
||||
if (ptr) {
|
||||
UINT8* p = (UINT8*)ptr;
|
||||
for (UINTN i = 0; i < total; i++) {
|
||||
p[i] = 0;
|
||||
}
|
||||
mem_set(ptr, 0, total);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
@@ -216,11 +214,7 @@ void* krealloc(void* ptr, UINTN new_size) {
|
||||
|
||||
void* new_ptr = kmalloc(new_size);
|
||||
if (new_ptr) {
|
||||
UINT8* src = (UINT8*)ptr;
|
||||
UINT8* dst = (UINT8*)new_ptr;
|
||||
for (UINTN i = 0; i < old_size; i++) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
mem_copy(new_ptr, ptr, old_size);
|
||||
kfree(ptr);
|
||||
}
|
||||
return new_ptr;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <memory/pmm.h>
|
||||
#include <common.h>
|
||||
#include <serial.h>
|
||||
#include <string_utils.h>
|
||||
|
||||
extern EFI_SYSTEM_TABLE *ST;
|
||||
|
||||
|
||||
@@ -53,12 +53,7 @@ task_t* task_create(const char* name, void (*entry)(void)) {
|
||||
task->time_slice = TIME_SLICE_DEFAULT;
|
||||
|
||||
// Copy name
|
||||
const char* s = name;
|
||||
char* d = task->name;
|
||||
for (SSINT32 i = 0; i < TASK_NAME_LEN - 1 && *s; i++) {
|
||||
*d++ = *s++;
|
||||
}
|
||||
*d = '\0';
|
||||
str_copy(task->name, name, TASK_NAME_LEN);
|
||||
|
||||
// Set up initial stack for first context_switch into this task.
|
||||
// Stack grows downward. context_switch will pop 6 regs then ret.
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#include <serial.h>
|
||||
#include <common.h>
|
||||
#include <string_utils.h>
|
||||
|
||||
extern EFI_SYSTEM_TABLE *ST;
|
||||
|
||||
@@ -22,7 +22,7 @@ void serial_write_char(char c) {
|
||||
}
|
||||
}
|
||||
|
||||
void serial_write(const char *str) {
|
||||
void serial_write(String str) {
|
||||
if (!g_serial.SerialIo) {
|
||||
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*)L"serial: null io\n");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user