diff --git a/include/dev.h b/include/dev.h index 5750a86..340d4e0 100644 --- a/include/dev.h +++ b/include/dev.h @@ -9,7 +9,7 @@ typedef struct { u32 num; } dev_t; -#define MAKE_DEV(driver, num) ((dev_t){&(driver), num}) +#define make_dev(driver, num) ((dev_t){&(driver), num}) isize dev_read(dev_t dev, u8 *buf, usize size); isize dev_write(dev_t dev, const u8 *buf, usize size); diff --git a/include/dev_table.h b/include/dev_table.h index 42330fc..302e4d3 100644 --- a/include/dev_table.h +++ b/include/dev_table.h @@ -18,5 +18,5 @@ typedef struct { i32 (*init)(const dev_node_t *node); } dev_init_t; -#define DEV_INIT(compat, func) \ +#define dev_init(compat, func) \ __section(.init.dev) __used static dev_init_t _dev_init = {compat, func} diff --git a/include/init.h b/include/init.h index 681d09f..bb1171d 100644 --- a/include/init.h +++ b/include/init.h @@ -3,11 +3,11 @@ #include #include -#define MODULE_PRE_INIT(func) \ +#define module_pre_init(func) \ __section(.init.pre_init) __used static i32 (*_pre_init)(void) = func -#define MODULE_INIT(func) \ +#define module_init(func) \ __section(.init.init) __used static i32 (*_init)(void) = func -#define MODULE_POST_INIT(func) \ +#define module_post_init(func) \ __section(.init.post_init) __used static i32 (*_post_init)(void) = func i32 init_modules(void); diff --git a/include/list.h b/include/list.h index c8808aa..6a90ebb 100644 --- a/include/list.h +++ b/include/list.h @@ -7,7 +7,7 @@ typedef struct list_node { struct list_node *prev, *next; } list_node_t; -#define LIST_HEAD_INIT(name) \ +#define list_head_init(name) \ { &name, &name } static inline void list_init_head(list_node_t *head) { diff --git a/src/dev_table.c b/src/dev_table.c index 12da046..150c784 100644 --- a/src/dev_table.c +++ b/src/dev_table.c @@ -21,4 +21,4 @@ static i32 init(void) { return 0; } -MODULE_POST_INIT(init); +module_post_init(init); diff --git a/src/drivers/fb.c b/src/drivers/fb.c index a051e73..dbf2243 100644 --- a/src/drivers/fb.c +++ b/src/drivers/fb.c @@ -27,7 +27,7 @@ static driver_t driver = { static i32 init(void) { return 0; } -MODULE_INIT(init); +module_init(init); i32 fb_register_dev(dev_t dev) { if (nr_devs == DRIVER_DEV_CAPACITY) @@ -35,7 +35,7 @@ i32 fb_register_dev(dev_t dev) { u32 num = nr_devs++; ctrl_blks[num].dev = dev; for (u32 i = 0; i < nr_dev_probes; i++) { - probes[i](MAKE_DEV(driver, num)); + probes[i](make_dev(driver, num)); } return 0; } @@ -45,7 +45,7 @@ i32 fb_register_dev_probe(void (*probe)(dev_t dev)) { return -EAGAIN; probes[nr_dev_probes++] = probe; for (u32 num = 0; num < nr_devs; num++) { - probe(MAKE_DEV(driver, num)); + probe(make_dev(driver, num)); } return 0; } diff --git a/src/drivers/fbcon.c b/src/drivers/fbcon.c index 9164fdd..bd6168e 100644 --- a/src/drivers/fbcon.c +++ b/src/drivers/fbcon.c @@ -174,7 +174,7 @@ static void init_dev(dev_t dev) { ctrl_blk->fg = DEFAULT_FG; ctrl_blk->bg = DEFAULT_BG; - tty_register_sink(dev.num, MAKE_DEV(driver, dev.num)); + tty_register_sink(dev.num, make_dev(driver, dev.num)); } static i32 init(void) { @@ -182,4 +182,4 @@ static i32 init(void) { return 0; } -MODULE_POST_INIT(init); +module_post_init(init); diff --git a/src/drivers/plic.c b/src/drivers/plic.c index 9c56e6f..607981d 100644 --- a/src/drivers/plic.c +++ b/src/drivers/plic.c @@ -29,4 +29,4 @@ static i32 init_dev(const dev_node_t *node) { return 0; } -DEV_INIT("plic", init_dev); +dev_init("plic", init_dev); diff --git a/src/drivers/tty.c b/src/drivers/tty.c index 21ec024..0b5226a 100644 --- a/src/drivers/tty.c +++ b/src/drivers/tty.c @@ -36,7 +36,7 @@ driver_t tty_driver = { static i32 init(void) { return 0; } -MODULE_INIT(init); +module_init(init); static void lazy_init_ctrl_blks(u32 num) { if (num < nr_devs) diff --git a/src/drivers/uart.c b/src/drivers/uart.c index 780e245..77c242d 100644 --- a/src/drivers/uart.c +++ b/src/drivers/uart.c @@ -130,4 +130,4 @@ static i32 init_dev(const dev_node_t *node) { return 0; } -DEV_INIT("uart", init_dev); +dev_init("uart", init_dev); diff --git a/src/drivers/virtio-gpu.c b/src/drivers/virtio-gpu.c index 84fb7df..1987958 100644 --- a/src/drivers/virtio-gpu.c +++ b/src/drivers/virtio-gpu.c @@ -383,4 +383,4 @@ static i32 init(void) { return 0; } -MODULE_POST_INIT(init); +module_post_init(init); diff --git a/src/mm/kalloc.c b/src/mm/kalloc.c index f710bb7..d5bedf3 100644 --- a/src/mm/kalloc.c +++ b/src/mm/kalloc.c @@ -11,7 +11,7 @@ typedef struct { usize size; } block_header_t; -static list_node_t block_list = LIST_HEAD_INIT(block_list); +static list_node_t block_list = list_head_init(block_list); void *kmalloc(usize size) { size += sizeof(block_header_t); diff --git a/src/mm/page_alloc.c b/src/mm/page_alloc.c index 5df7a25..6234e5c 100644 --- a/src/mm/page_alloc.c +++ b/src/mm/page_alloc.c @@ -6,7 +6,7 @@ extern u8 _heap_start[KHEAP_SIZE]; -static list_node_t free_list = LIST_HEAD_INIT(free_list); +static list_node_t free_list = list_head_init(free_list); static i32 init(void) { list_node_t *node = (list_node_t *) _heap_start; @@ -17,7 +17,7 @@ static i32 init(void) { return 0; } -MODULE_PRE_INIT(init); +module_pre_init(init); void *page_alloc(void) { if (list_empty(&free_list)) diff --git a/src/sched.c b/src/sched.c index 6fb75fb..31f6e8d 100644 --- a/src/sched.c +++ b/src/sched.c @@ -3,7 +3,7 @@ #include #include -static list_node_t ready_queue = LIST_HEAD_INIT(ready_queue); +static list_node_t ready_queue = list_head_init(ready_queue); static proc_t idle_proc; static timer_t timer; @@ -26,7 +26,7 @@ static i32 init(void) { return 0; } -MODULE_POST_INIT(init); +module_post_init(init); void sched_update_state(proc_t *proc, proc_state_t state) { if (proc->state == state) diff --git a/src/timer.c b/src/timer.c index 149bdfa..631fc43 100644 --- a/src/timer.c +++ b/src/timer.c @@ -6,14 +6,14 @@ extern const u32 TIMER_FREQ; -static list_node_t wait_queue = LIST_HEAD_INIT(wait_queue); +static list_node_t wait_queue = list_head_init(wait_queue); static i32 init(void) { csr_set_bits(sie, CSR_SIE_STIE); return sbi_set_timer(TIME_MAX); } -MODULE_INIT(init); +module_init(init); void timer_init(timer_t *timer) { list_init_head(&timer->node); } diff --git a/src/trap.c b/src/trap.c index 90e6c5b..c0f84ed 100644 --- a/src/trap.c +++ b/src/trap.c @@ -14,7 +14,7 @@ static i32 init(void) { return 0; } -MODULE_PRE_INIT(init); +module_pre_init(init); void trap_handler(trapframe_t *frame) { if (frame->scause & CSR_SCAUSE_INTR) {