From 4c51abf0668e3ba9187714f1702d098dd7addc1e Mon Sep 17 00:00:00 2001 From: Taku Shimosawa Date: Thu, 13 Oct 2011 11:49:15 +0900 Subject: [PATCH] ikc test listener added --- kernel/Makefile.build | 2 +- kernel/listeners.c | 37 +++++++++++++++++++++++++++++++++++++ kernel/mem.c | 26 ++++++++++++++++++++++++++ kernel/mikc.c | 9 +++++---- kernel/setup.c | 4 +++- 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 kernel/listeners.c diff --git a/kernel/Makefile.build b/kernel/Makefile.build index a7274ac8..2015eb2a 100644 --- a/kernel/Makefile.build +++ b/kernel/Makefile.build @@ -1,5 +1,5 @@ AALDIR=$(AALBASE)/$(TARGET) -OBJS=setup.o mem.o debug.o mikc.o +OBJS=setup.o mem.o debug.o mikc.o listeners.o DEPSRCS=$(wildcard $(SRC)/*.c) include $(SRC)/configs/config.$(TARGET) diff --git a/kernel/listeners.c b/kernel/listeners.c new file mode 100644 index 00000000..c113852f --- /dev/null +++ b/kernel/listeners.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include +#include + +static int test_packet_handler(struct aal_ikc_channel_desc *c, + void *__packet, void *__os) +{ + + return 0; +} + +static int test_handler(struct aal_ikc_channel_info *param) +{ + kprintf("Test connected : %p\n", param->channel); + + param->packet_handler = test_packet_handler; + + return 0; +} + +static struct aal_ikc_listen_param test_listen_param = { + .port = 500, + .handler = test_handler, + .pkt_size = sizeof(struct ikc_test_packet), + .queue_size = 4096, + .magic = 0x29, +}; + +void mc_ikc_init(void) +{ + aal_ikc_listen_port(NULL, &test_listen_param); + kprintf("Listener registered port %d\n", 500); +} diff --git a/kernel/mem.c b/kernel/mem.c index 39739433..d1e8a166 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -86,6 +86,32 @@ static void virtual_allocator_init(void) MAP_VMAP_SIZE, LARGE_PAGE_SIZE); } +void *aal_mc_map_virtual(unsigned long phys, int npages, + enum aal_mc_pt_attribute attr) +{ + void *p; + unsigned long i; + + p = (void *)aal_pagealloc_alloc(vmap_allocator, npages); + if (!p) { + return NULL; + } + for (i = 0; i < npages; i++) { + aal_mc_pt_set_page(NULL, (char *)p + (i << PAGE_SHIFT), + phys + (i << PAGE_SHIFT), attr); + } + return p; +} + +void aal_mc_unmap_virtual(void *va, int npages) +{ + unsigned long i; + + for (i = 0; i < npages; i++) { + aal_mc_pt_clear_page(NULL, (char *)va + (i << PAGE_SHIFT)); + } + aal_pagealloc_free(vmap_allocator, virt_to_phys(va), npages); +} void mem_init(void) { diff --git a/kernel/mikc.c b/kernel/mikc.c index e418e6e6..701b1586 100644 --- a/kernel/mikc.c +++ b/kernel/mikc.c @@ -2,19 +2,20 @@ #include #include #include +#include static struct aal_ikc_channel_desc mchannel; -static int master_channel_packet_handler(struct aal_ikc_channel_desc *, +static int arch_master_channel_packet_handler(struct aal_ikc_channel_desc *, void *__packet, void *arg); void ikc_master_init(void) { - aal_mc_ikc_init_first(&mchannel, master_channel_packet_handler); + aal_mc_ikc_init_first(&mchannel, arch_master_channel_packet_handler); kprintf("done.\n"); } -static int master_channel_packet_handler(struct aal_ikc_channel_desc *c, - void *__packet, void *arg) +static int arch_master_channel_packet_handler(struct aal_ikc_channel_desc *c, + void *__packet, void *arg) { struct aal_ikc_master_packet *packet = __packet; diff --git a/kernel/setup.c b/kernel/setup.c index ca656ef8..558f41e2 100644 --- a/kernel/setup.c +++ b/kernel/setup.c @@ -11,6 +11,7 @@ extern void kmsg_init(void); extern void mem_init(void); extern void ikc_master_init(void); extern void arch_ready(void); +extern void mc_ikc_init(void); int main(void) { @@ -24,8 +25,9 @@ int main(void) ikc_master_init(); - arch_ready(); + mc_ikc_init(); + arch_ready(); cpu_enable_interrupt(); while (1) { cpu_halt();