ikc test listener added

This commit is contained in:
Taku Shimosawa
2011-10-13 11:49:15 +09:00
parent f0a13df45e
commit 4c51abf066
5 changed files with 72 additions and 6 deletions

View File

@ -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)

37
kernel/listeners.c Normal file
View File

@ -0,0 +1,37 @@
#include <types.h>
#include <kmsg.h>
#include <aal/cpu.h>
#include <aal/mm.h>
#include <aal/debug.h>
#include <aal/ikc.h>
#include <ikc/master.h>
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);
}

View File

@ -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)
{

View File

@ -2,19 +2,20 @@
#include <aal/cpu.h>
#include <aal/debug.h>
#include <aal/ikc.h>
#include <ikc/msg.h>
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;

View File

@ -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();