Remove kernel procs

This commit is contained in:
2025-09-29 21:27:46 +02:00
parent 8db585f581
commit 20a89502c0
7 changed files with 0 additions and 157 deletions

View File

@ -1,16 +0,0 @@
#include <stdint.h>
#include "proc/proc.h"
#include "hal/hal.h"
#include "ipc/pipe/pipe.h"
#include "kprintf.h"
Proc *KPROC;
void kproc_init(Proc *proc) {
KPROC = proc;
}
void kproc_fn(void) {
for (;;) {
}
}

View File

@ -1,11 +0,0 @@
#ifndef PROC_KPROC_KPROC_H_
#define PROC_KPROC_KPROC_H_
#include "proc/proc.h"
extern Proc *KPROC;
void kproc_fn(void);
void kproc_init(Proc *proc);
#endif // PROC_KPROC_KPROC_H_

View File

@ -13,8 +13,6 @@
#include "vfs/vfs.h"
#include "bootinfo/bootinfo.h"
#include "ipc/pipe/pipe.h"
#include "kproc/kproc.h"
#include "serialproc/serialproc.h"
#include "sysdefs/processctl.h"
#define PROC_REAPER_FREQ 30
@ -75,41 +73,6 @@ ElfAuxval proc_load_elf_segs(Proc *proc, uint8_t *data) {
return aux;
}
Proc *proc_spawnkern(void (*ent)(void), char *name) {
if (pids >= PROC_MAX) {
return NULL;
}
Proc *proc = dlmalloc(sizeof(*proc));
if (proc == NULL) {
return NULL;
}
hal_memset(proc, 0, sizeof(*proc));
hal_memcpy(proc->name, name, PROC_NAME_MAX);
proc->kern = true;
uint8_t *pstackp = (uint8_t *)pmm_alloc(PROC_STACKBLOCKS) + PROC_STACKSIZE;
uint8_t *kstackp = (uint8_t *)pmm_alloc(PROC_STACKBLOCKS) + PROC_STACKSIZE;
proc->platformdata.kstack = kstackp;
proc->platformdata.pstack = pstackp;
hal_memset(&proc->platformdata.trapframe, 0, sizeof(proc->platformdata.trapframe));
proc->platformdata.trapframe.ss = 0x10;
proc->platformdata.trapframe.rsp = (uint64_t)VIRT(pstackp);
proc->platformdata.trapframe.rflags = 0x202;
proc->platformdata.trapframe.cs = 0x08;
proc->platformdata.trapframe.rip = (uint64_t)ent;
proc->platformdata.cr3 = KERNEL_CR3;
proc->state = PROC_EMBRYO;
proc->pid = pids++;
spinlock_init(&proc->bcast_pipes.spinlock);
spinlock_init(&proc->pipes_spinlock);
return proc;
}
Proc *proc_spawnuser(char *mountpoint, char *path) {
VfsObj *vobj = vfs_open(mountpoint, path, VFS_FLAG_READ);
if (vobj == NULL) {

View File

@ -88,7 +88,6 @@ extern Procs PROCS;
void proc_init(void);
void proc_register(Proc *proc);
Proc *proc_spawnkern(void (*ent)(void), char *name);
Proc *proc_spawnuser(char *mountpoint, char *path);
void proc_sched(void *cpustate);
void proc_killself(void);

View File

@ -1,79 +0,0 @@
#include <stdint.h>
#include <stddef.h>
#include "proc/proc.h"
#include "ipc/pipe/pipe.h"
#include "hal/hal.h"
#include "dlmalloc/malloc.h"
#define SERIAL_PORT 0x3f8
Proc *SERIALPROC;
void serialproc_init(Proc *proc) {
SERIALPROC = proc;
SERIALPROC->pipes[0] = dlmalloc(sizeof(IpcPipe));
ipc_pipeinit(SERIALPROC->pipes[0], SERIALPROC->pid);
SERIALPROC->pipes[1] = dlmalloc(sizeof(IpcPipe));
ipc_pipeinit(SERIALPROC->pipes[1], SERIALPROC->pid);
io_out8(SERIAL_PORT + 1, 0x00);
io_out8(SERIAL_PORT + 3, 0x80);
io_out8(SERIAL_PORT + 0, 0x03);
io_out8(SERIAL_PORT + 1, 0x00);
io_out8(SERIAL_PORT + 3, 0x03);
io_out8(SERIAL_PORT + 2, 0xc7);
io_out8(SERIAL_PORT + 4, 0x0b);
io_out8(SERIAL_PORT + 4, 0x1e);
io_out8(SERIAL_PORT + 0, 0xae);
if (io_in8(SERIAL_PORT + 0) != 0xae) {
return;
}
io_out8(SERIAL_PORT + 4, 0x0f);
}
int serialproc_received(void) {
return io_in8(SERIAL_PORT + 5) & 1;
}
uint8_t serialproc_read(void) {
while (serialproc_received() == 0);
return io_in8(SERIAL_PORT);
}
int serialproc_trans_empty(void) {
return io_in8(SERIAL_PORT + 5) & 0x20;
}
void serialproc_write(uint8_t value) {
while (!serialproc_trans_empty());
io_out8(SERIAL_PORT, value);
}
void serialproc_fn(void) {
char buf[0x100];
for (;;) {
hal_memset(buf, 0, sizeof(buf));
spinlock_acquire(&SERIALPROC->pipes_spinlock);
IpcPipe *inpipe = SERIALPROC->pipes[1];
spinlock_release(&SERIALPROC->pipes_spinlock);
int32_t read = ipc_piperead(inpipe, (uint8_t *)buf, sizeof(buf));
if (read > 0) {
for (size_t i = 0; i < sizeof(buf); i++) {
serialproc_write(buf[i]);
}
}
if (serialproc_received() == 0) {
continue;
}
uint8_t inchar = io_in8(SERIAL_PORT);
spinlock_acquire(&SERIALPROC->pipes_spinlock);
IpcPipe *outpipe = SERIALPROC->pipes[0];
spinlock_release(&SERIALPROC->pipes_spinlock);
ipc_pipewrite(outpipe, &inchar, sizeof(inchar));
}
}

View File

@ -1,11 +0,0 @@
#ifndef PROC_SERIALPROC_SERIALPROC_H_
#define PROC_SERIALPROC_SERIALPROC_H_
#include "proc/proc.h"
extern Proc *SERIALPROC;
void serialproc_init(Proc *proc);
void serialproc_fn(void);
#endif // PROC_SERIALPROC_SERIALPROC_H_