UART service tested.

This commit is contained in:
Amit Mahajan
2009-11-25 22:55:36 +05:30
parent 26268a30d2
commit d18751fbe8
3 changed files with 17 additions and 13 deletions

View File

@@ -140,7 +140,6 @@ int uart_probe_devices(void)
for (int i = 0; i < total_caps; i++) { for (int i = 0; i < total_caps; i++) {
/* Match device type */ /* Match device type */
if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_UART) { if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_UART) {
printf("got uart\n");
/* Copy to correct device index */ /* Copy to correct device index */
memcpy(&uart_cap[cap_devnum(&caparray[i]) - 1], memcpy(&uart_cap[cap_devnum(&caparray[i]) - 1],
&caparray[i], sizeof(uart_cap[0])); &caparray[i], sizeof(uart_cap[0]));
@@ -161,12 +160,13 @@ static struct pl011_uart uart[UARTS_TOTAL];
int uart_setup_devices(void) int uart_setup_devices(void)
{ {
for (int i = 0; i < UARTS_TOTAL; i++) { for (int i = 0; i < UARTS_TOTAL; i++) {
/* Get one page from address pool */
uart[i].base = (unsigned long)l4_new_virtual(1);
/* Map uart to a virtual address region */ /* Map uart to a virtual address region */
if (IS_ERR(uart[i].base = if (IS_ERR(l4_map((void *)__pfn_to_addr(uart_cap[i].start),
l4_map((void *)__pfn_to_addr(uart_cap[i].start), (void *)uart[i].base, uart_cap[i].size, MAP_USR_IO_FLAGS,
l4_new_virtual(uart_cap[i].size), self_tid()))) {
uart_cap[i].size,
MAP_USR_IO_FLAGS, self_tid()))) {
printf("%s: FATAL: Failed to map UART device " printf("%s: FATAL: Failed to map UART device "
"%d to a virtual address\n", "%d to a virtual address\n",
__CONTAINER_NAME__, __CONTAINER_NAME__,
@@ -223,10 +223,10 @@ out_err:
BUG(); BUG();
} }
void *l4_new_virtual(int npages)
void *l4_new_virtual(int size)
{ {
return address_new(&device_vaddr_pool, 1, size);
return address_new(&device_vaddr_pool, npages, PAGE_SIZE);
} }
void uart_generic_tx(char c, int devno) void uart_generic_tx(char c, int devno)
@@ -236,7 +236,11 @@ void uart_generic_tx(char c, int devno)
char uart_generic_rx(int devno) char uart_generic_rx(int devno)
{ {
return 0; char c;
pl011_rx_char(uart[devno].base, &c);
return c;
} }
void handle_requests(void) void handle_requests(void)

View File

@@ -62,7 +62,7 @@
#define PL011_OEIRQ (1 << 10) #define PL011_OEIRQ (1 << 10)
struct pl011_uart { struct pl011_uart {
unsigned int base; unsigned long base;
unsigned int frame_errors; unsigned int frame_errors;
unsigned int parity_errors; unsigned int parity_errors;
unsigned int break_errors; unsigned int break_errors;

View File

@@ -358,7 +358,6 @@ int memcap_request_device(struct cap_list *cap_list,
__pfn_to_addr(devcap->end), devcap->attr); __pfn_to_addr(devcap->end), devcap->attr);
BUG(); BUG();
} }
/* /*
* TODO: Evaluate if access bits are needed and add new cap ranges * TODO: Evaluate if access bits are needed and add new cap ranges
* only if their access bits match. * only if their access bits match.
@@ -517,6 +516,7 @@ int copy_pager_info(struct pager *pager, struct pager_info *pinfo)
cap->start = cap_info->start; cap->start = cap_info->start;
cap->end = cap_info->end; cap->end = cap_info->end;
cap->size = cap_info->size; cap->size = cap_info->size;
cap->uattr = cap_info->uattr;
cap_list_insert(cap, &pager->cap_list); cap_list_insert(cap, &pager->cap_list);
} }