Move string functions/utils from HAL to std/string

This commit is contained in:
2025-11-11 19:54:09 +01:00
parent f5dae4984d
commit 344952fb5f
27 changed files with 200 additions and 228 deletions

View File

@ -16,6 +16,7 @@
#include "sysdefs/proc.h"
#include "sysdefs/fs.h"
#include "time/time.h"
#include "std/string.h"
#define PROC_REAPER_FREQ 30
@ -53,8 +54,8 @@ ElfAuxval proc_load_elf_segs(Proc *proc, uint8_t *data) {
uint8_t *physaddr = pmm_alloc(blocks);
uint8_t *virtaddr = (uint8_t *)(phdr->p_vaddr & ~(HAL_PAGE_SIZE - 1));
hal_memset(VIRT(physaddr), 0, blocks * HAL_PAGE_SIZE);
hal_memcpy(VIRT(physaddr) + off, (data + phdr->p_offset), phdr->p_filesz);
memset(VIRT(physaddr), 0, blocks * HAL_PAGE_SIZE);
memcpy(VIRT(physaddr) + off, (data + phdr->p_offset), phdr->p_filesz);
uint32_t pgflags = HAL_PG_USER | HAL_PG_PRESENT;
if (phdr->p_flags & PF_W) {
@ -105,10 +106,10 @@ Proc *proc_spawnuser(char *mountpoint, char *path) {
vfs_close(vobj);
Proc *proc = dlmalloc(sizeof(*proc));
hal_memset(proc, 0, sizeof(*proc));
memset(proc, 0, sizeof(*proc));
ksprintf(proc->name, "%s:%s", mountpoint, path);
hal_memset(&proc->platformdata.trapframe, 0, sizeof(proc->platformdata.trapframe));
memset(&proc->platformdata.trapframe, 0, sizeof(proc->platformdata.trapframe));
proc->platformdata.cr3 = hal_vmm_userproc_pml4_phys();
uint8_t *kstackp = (uint8_t *)pmm_alloc(PROC_STACKBLOCKS) + PROC_STACKSIZE;
@ -223,7 +224,7 @@ void proc_sched(void *cpustate) {
hal_intr_disable();
sched_ticks++;
hal_memcpy(&PROCS.current->platformdata.trapframe, cpustate, sizeof(IntrStackFrame));
memcpy(&PROCS.current->platformdata.trapframe, cpustate, sizeof(IntrStackFrame));
PROCS.current = proc_nextready();

View File

@ -10,6 +10,7 @@
#include "sysdefs/proc.h"
#include "sysdefs/time.h"
#include "dev/dev.h"
#include "std/string.h"
#define PROC_NAME_MAX 0x100
@ -90,7 +91,7 @@ void proc_kill(Proc *proc);
#define PROC_ARG(proc, str) \
do { \
ProcArg *__arg = dlmalloc(sizeof(*__arg)); \
hal_strcpy(__arg->string, (str)); \
strcpy(__arg->string, (str)); \
LL_APPEND((proc)->procargs.list, __arg); \
(proc)->procargs.len++; \
} while(0)