Draft: lab 5 failed

This commit is contained in:
2025-05-03 20:45:34 +08:00
parent 981cae803b
commit e73f90395d
39 changed files with 588 additions and 429 deletions

View File

@@ -1,23 +1,22 @@
#include <logger.h>
#include <timer.h>
#include <process.h>
#include <thread.h>
#include <kmalloc.h>
#include <uart.h>
#include <dtb.h>
#include <initrd.h>
#include <mman.h>
#include <shell.h>
#include <vector.h>
#include <utils.h>
#include <thread.h>
#include <timer.h>
#include <exception.h>
#include <interrupt.h>
static inline
void _init(void *dtb, file_node_t **initrd_root)
void _init(void *dtb)
{
init_exception();
exception_init();
// UART
uart_init();
// Device tree
@@ -29,56 +28,22 @@ void _init(void *dtb, file_node_t **initrd_root)
fdt_traverse(dtb_struct_cbs);
DEBUG_DTB("device tree parse done");
// Initramfs
DEBUG_INITRD(initrd_start);
*initrd_root = initrd_init();
initrd_init();
// Memory (Buddy system)
mman_init();
// Threads
thread_init();
init_interrupt();
}
timer_init();
static inline
void _print_time(uint64_t)
{
uint64_t cntpct_el0, cntfrq_el0;
R_SYSREG(cntpct_el0, cntpct_el0);
R_SYSREG(cntfrq_el0, cntfrq_el0);
DEBUG_EXCEP(cntpct_el0 / cntfrq_el0);
task_t task = {
.firing_tick = cntpct_el0 + 2 * cntfrq_el0,
.interval = 2 * cntfrq_el0,
.repeat = 1,
.func = _print_time,
.param = 0x0,
};
add_timer_task(task);
}
static inline
int32_t _test(uint64_t)
{
for (int i = 0; i < 10; ++i) {
LOG(i); DEBUG_THREAD(get_current());
sleep(1000000);
}
return 0;
enable_interrupt();
}
void main(void *dtb)
{
file_node_t *initrd_root = 0x0;
_init(dtb, &initrd_root);
_init(dtb);
for (int i = 0; i < 3; ++i)
run_thread(_test, 0x0);
run_thread(run_process_by_name, (uint64_t)&"syscall.img");
schedule();
}