Draft: lab 5 failed
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
void init_exception(void);
|
||||
#include <stddef.h>
|
||||
#include <process.h>
|
||||
|
||||
void exception_vector_table(void);
|
||||
|
||||
void exception_init(void);
|
||||
void not_implemented_handler(void);
|
||||
void synchronous_handler(void);
|
||||
void synchronous_handler(trapframe_t *regs);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
void user_exec(void *text, void *sp);
|
||||
#include <process.h>
|
||||
|
||||
void user_exec(trapframe_t *regs);
|
||||
|
||||
@@ -45,7 +45,7 @@ typedef struct file_node {
|
||||
|
||||
typedef void (*initrd_callback_func_t)(file_node_t *);
|
||||
|
||||
file_node_t *initrd_init(void);
|
||||
void initrd_init(void);
|
||||
void initrd_fdt_callback(const vector_t *props);
|
||||
file_node_t *initrd_get(file_node_t *root, const char *filename);
|
||||
void initrd_traverse(file_node_t *tr, initrd_callback_func_t func);
|
||||
@@ -53,3 +53,4 @@ void initrd_traverse(file_node_t *tr, initrd_callback_func_t func);
|
||||
extern fdt_callback_t initrd_dtb_cb;
|
||||
extern void *initrd_start;
|
||||
extern void *initrd_end;
|
||||
extern file_node_t *initrd_root;
|
||||
|
||||
@@ -22,7 +22,6 @@ void add_interrupt_task(uint64_t priority,
|
||||
interrupt_callback_func_t func,
|
||||
uint64_t param);
|
||||
|
||||
void init_interrupt(void);
|
||||
void irq_handler(void);
|
||||
|
||||
void wfe(void);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
/* a properly aligned buffer */
|
||||
extern volatile unsigned int mbox[36];
|
||||
// extern volatile unsigned int mbox[36];
|
||||
|
||||
#define MBOX_REQUEST 0
|
||||
|
||||
@@ -45,7 +45,7 @@ extern volatile unsigned int mbox[36];
|
||||
#define MBOX_TAG_GETSERIAL 0x00010004
|
||||
#define MBOX_TAG_ARM_MEMORY 0x00010005
|
||||
|
||||
int mbox_call(unsigned char ch);
|
||||
int mbox_call(unsigned char ch, unsigned int *mbox);
|
||||
unsigned int get_board_revision(void);
|
||||
unsigned int get_memory_base_addr(void);
|
||||
unsigned int get_memory_size(void);
|
||||
|
||||
53
kernel/include/process.h
Normal file
53
kernel/include/process.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct {
|
||||
uint64_t x0, x1;
|
||||
uint64_t x2, x3;
|
||||
uint64_t x4, x5;
|
||||
uint64_t x6, x7;
|
||||
uint64_t x8, x9;
|
||||
uint64_t x10, x11;
|
||||
uint64_t x12, x13;
|
||||
uint64_t x14, x15;
|
||||
uint64_t x16, x17;
|
||||
uint64_t x18, x19;
|
||||
uint64_t x20, x21;
|
||||
uint64_t x22, x23;
|
||||
uint64_t x24, x25;
|
||||
uint64_t x26, x27;
|
||||
uint64_t x28, fp;
|
||||
uint64_t lr, spsr_el1;
|
||||
uint64_t elr_el1;
|
||||
uint64_t esr_el1;
|
||||
uint64_t sp_el0;
|
||||
} trapframe_t;
|
||||
|
||||
struct thread;
|
||||
|
||||
typedef struct process {
|
||||
int32_t pid;
|
||||
struct thread *th;
|
||||
|
||||
int32_t exitcode;
|
||||
|
||||
void *stack;
|
||||
size_t stack_size;
|
||||
|
||||
void *mem;
|
||||
size_t mem_size;
|
||||
|
||||
trapframe_t *regs;
|
||||
} process_t;
|
||||
|
||||
// thread_func_t, cast from
|
||||
// void run_process_by_name(const char *filename)
|
||||
int32_t run_process_by_name(uint64_t filename);
|
||||
|
||||
// void run_process(process_t *)
|
||||
int32_t run_process(uint64_t process);
|
||||
|
||||
process_t *fork_process(const process_t *from);
|
||||
|
||||
extern int32_t global_pid_counter;
|
||||
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <initrd.h>
|
||||
|
||||
int // is continue
|
||||
shell(file_node_t *);
|
||||
15
kernel/include/syscall.h
Normal file
15
kernel/include/syscall.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <process.h>
|
||||
|
||||
void syscall_handler(trapframe_t *regs);
|
||||
|
||||
int32_t sys_getpid(void);
|
||||
size_t sys_uart_read(char buf[], size_t size);
|
||||
size_t sys_uart_write(const char buf[], size_t size);
|
||||
int32_t sys_exec(const char *name, char *const argv[]);
|
||||
int32_t sys_fork(void);
|
||||
void sys_exit(int32_t status);
|
||||
int32_t sys_mbox_call(uint8_t ch, uint32_t *mbox);
|
||||
void sys_kill(int32_t pid);
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <queue.h>
|
||||
#include <process.h>
|
||||
|
||||
typedef int32_t (*thread_func_t)(uint64_t);
|
||||
|
||||
@@ -20,21 +21,21 @@ typedef struct {
|
||||
uint64_t x27, x28;
|
||||
uint64_t fp, lr;
|
||||
uint64_t sp;
|
||||
uint64_t sp_el0;
|
||||
uint64_t elr_el1;
|
||||
} cpu_state_t;
|
||||
|
||||
typedef struct {
|
||||
typedef struct thread {
|
||||
thread_func_t func;
|
||||
uint64_t param;
|
||||
|
||||
thread_status_t status;
|
||||
int32_t retcode;
|
||||
|
||||
void *stack_pointer;
|
||||
void *stack;
|
||||
size_t stack_size;
|
||||
|
||||
cpu_state_t regs;
|
||||
cpu_state_t *regs;
|
||||
|
||||
process_t *process;
|
||||
} thread_t;
|
||||
|
||||
// thread.S
|
||||
|
||||
@@ -7,7 +7,6 @@ typedef void (*task_callback_func_t)(uint64_t);
|
||||
typedef struct {
|
||||
uint64_t firing_tick;
|
||||
uint64_t interval;
|
||||
uint64_t repeat;
|
||||
|
||||
task_callback_func_t func;
|
||||
uint64_t param;
|
||||
@@ -20,6 +19,8 @@ typedef struct timer {
|
||||
task_t data;
|
||||
} timer_t;
|
||||
|
||||
void timer_init(void);
|
||||
|
||||
void add_timer_task(task_t task);
|
||||
void sleep(uint64_t ms);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ int isspace(int);
|
||||
int32_t atoi32(const char *);
|
||||
uint32_t atoh32(const char *);
|
||||
|
||||
void exit(int);
|
||||
void panic(int errno);
|
||||
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#define MAX(x, y) (((x) < (y)) ? (y) : (x))
|
||||
|
||||
Reference in New Issue
Block a user