Testing Inter container IPC for UART service

This commit is contained in:
Amit Mahajan
2009-11-25 12:24:53 +05:30
parent a10a77a0a0
commit b53cc73747
6 changed files with 29 additions and 25 deletions

View File

@@ -144,7 +144,7 @@ cap_strings = { 'ipc' : \
\t\t\t[${idx}] = {
\t\t\t\t/* For device selection */
\t\t\t\t.target = ${cid},
\t\t\t\t.uattr = CAP_DEVTYPE_UART | ${devnum},
\t\t\t\t.uattr = CAP_DEVTYPE_UART | (${devnum} << 16),
\t\t\t\t.type = CAP_TYPE_MAP_PHYSMEM | CAP_RTYPE_CONTAINER,
\t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE | CAP_MAP_EXEC |
\t\t\t\t\tCAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP | CAP_MAP_UTCB,

View File

@@ -122,9 +122,9 @@ int cap_read_all()
"complete CAP_CONTROL_READ_CAPS request.\n");
BUG();
}
#if 0
cap_array_print(&caparray);
#endif
return 0;
}
@@ -149,7 +149,7 @@ int uart_probe_devices(void)
if (uarts != UARTS_TOTAL) {
printf("%s: Error, not all uarts could be found. "
"uarts=%d\n", __CONTAINER_NAME__, uarts);
BUG();
return -ENODEV;
}
return 0;
}
@@ -158,8 +158,6 @@ static struct pl011_uart uart[UARTS_TOTAL];
int uart_setup_devices(void)
{
BUG(); /* Make sure to have set the device capability size as well */
for (int i = 0; i < UARTS_TOTAL; i++) {
/* Map uart to a virtual address region */
if (IS_ERR(uart[i].base =
@@ -177,6 +175,7 @@ int uart_setup_devices(void)
/* Initialize uart */
pl011_initialise(&uart[i]);
}
return 0;
}
static struct address_pool device_vaddr_pool;
@@ -207,10 +206,8 @@ void init_vaddr_pool(void)
* We may allocate virtual memory
* addresses from this pool.
*/
address_pool_init(&device_vaddr_pool,
(unsigned long)__end,
__pfn_to_addr(caparray[i].end),
UARTS_TOTAL);
address_pool_init(&device_vaddr_pool, page_align_up(__end),
__pfn_to_addr(caparray[i].end), UARTS_TOTAL);
return;
} else
goto out_err;
@@ -226,7 +223,7 @@ out_err:
void uart_generic_tx(char c, int devno)
{
pl011_tx_char(uart[devno].base, *c);
}
char uart_generic_rx(int devno)
@@ -234,7 +231,6 @@ char uart_generic_rx(int devno)
return 0;
}
void handle_requests(void)
{
l4id_t senderid;
@@ -265,10 +261,10 @@ void handle_requests(void)
*/
switch (tag) {
case L4_IPC_TAG_UART_SENDCHAR:
uart_generic_tx(0, 0); /*FIXME: Fill in */
uart_generic_tx(0, 1); /*FIXME: Fill in */
break;
case L4_IPC_TAG_UART_RECVCHAR:
uart_generic_rx(0); /* FIXME: Fill in */
uart_generic_rx(1); /* FIXME: Fill in */
break;
default:
printf("%s: Error received ipc from 0x%x residing "

View File

@@ -20,7 +20,7 @@ int address_pool_init_with_idpool(struct address_pool *pool,
unsigned long start, unsigned long end);
int address_pool_init(struct address_pool *pool,
unsigned long start, unsigned long end,
int size);
unsigned int size);
void *address_new(struct address_pool *pool, int nitems, int size);
int address_del(struct address_pool *, void *addr, int nitems, int size);

View File

@@ -24,9 +24,9 @@ int address_pool_init_with_idpool(struct address_pool *pool,
int address_pool_init(struct address_pool *pool,
unsigned long start, unsigned long end,
int size)
unsigned int size)
{
if ((pool->idpool = id_pool_new_init((end - start) / size)) < 0)
if ((pool->idpool = id_pool_new_init(__pfn(end - start) / size)) < 0)
return (int)pool->idpool;
pool->start = start;
pool->end = end;

View File

@@ -58,7 +58,7 @@
(c)->attr |= CAP_DEVTYPE_MASK & devtype;}
#define cap_set_devnum(c, devnum) \
{(c)->attr &= ~CAP_DEVNUM_MASK; \
(c)->attr |= CAP_DEVNUM_MASK & devnum;}
(c)->attr |= CAP_DEVNUM_MASK & (devnum << CAP_DEVNUM_SHIFT);}
#define cap_devnum(c) \
(((c)->attr & CAP_DEVNUM_MASK) >> CAP_DEVNUM_SHIFT)
#define cap_devtype(c) ((c)->attr & CAP_DEVTYPE_MASK)

View File

@@ -334,13 +334,21 @@ int memcap_request_device(struct cap_list *cap_list,
struct capability *cap, *n;
list_foreach_removable_struct(cap, n, &cap_list->caps, list) {
if (cap->start == devcap->start &&
cap->end == devcap->end &&
cap_is_devmem(cap)) {
/* Unlink only. This is boot memory */
list_remove(&cap->list);
return 0;
}
if (cap->uattr[0] == devcap->uattr[0]) {
/*
* We dont want the user to provide, start end addresses,
* just selecting the type of device to be used is fine
*/
devcap->start = cap->start;
devcap->end = cap->end;
devcap->size = cap->size;
/* Unlink only. This is boot memory */
list_remove(&cap->list);
return 0;
}
}
printk("%s: FATAL: Device memory requested "
"does not match any available device "