1/1

|
[or1ksim #21] Pass a caller given pointer to the vapi_read callback
by Unknown on Feb 4, 2005 |
Not available! | ||
|
Hi,
Changelog says it all. ChangeLog: * Pass a caller given pointer to the vapi_read callback. nog. -------------- next part -------------- --- vapi/vapi.c 2005-02-04 12:18:46.000000000 +0100 +++ ../or1ksim-ac/vapi/vapi.c 2005-02-04 14:24:35.000000000 +0100 @@ -61,7 +61,8 @@ static struct vapi_handler { int fd; unsigned long base_id, num_ids; - void (*read_func)(unsigned long, unsigned long); + void (*read_func)(unsigned long, unsigned long, void *); + void *priv_dat; struct vapi_handler *next; int temp; } *vapi_handler = NULL; @@ -121,6 +122,7 @@ tt->base_id = base_id; tt->num_ids = num_ids; tt->read_func = NULL; + tt->priv_dat = NULL; tt->fd = 0; (*t) = tt; free (fds); @@ -430,7 +432,7 @@ if (!t || !t->read_func) fprintf (stderr, "WARNING: Received packet for undefined id %08lx, data %08lx\n", id, data); else - t->read_func(id, data); + t->read_func(id, data, t->priv_dat); } void vapi_check () @@ -538,13 +540,13 @@ } /* Installs a vapi handler for one VAPI id */ -void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long)) +void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long, void *), void *dat) { - vapi_install_multi_handler (id, 1, read_func); + vapi_install_multi_handler (id, 1, read_func, dat); } /* Installs a vapi handler for many VAPI id */ -void vapi_install_multi_handler (unsigned long base_id, unsigned long num_ids, void (*read_func) (unsigned long, unsigned long)) +void vapi_install_multi_handler (unsigned long base_id, unsigned long num_ids, void (*read_func) (unsigned long, unsigned long, void *), void *dat) { struct vapi_handler *tt; @@ -567,8 +569,10 @@ if (!tt) { tt = add_handler (base_id, num_ids); tt->read_func = read_func; + tt->priv_dat = dat; } else { tt->read_func = read_func; + tt->priv_dat = dat; rebuild_fds (); } } --- vapi/vapi.h 2002-02-05 09:57:39.000000000 +0100 +++ ../or1ksim-ac/vapi/vapi.h 2005-02-04 14:23:55.000000000 +0100 @@ -30,10 +30,10 @@ void vapi_done (); /* Installs a vapi handler for one VAPI id */ -void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long)); +void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long, void *), void *dat); /* Installs a vapi handler for multiple VAPI id */ -void vapi_install_multi_handler (unsigned long base_id, unsigned long num_ids, void (*read_func) (unsigned long, unsigned long)); +void vapi_install_multi_handler (unsigned long base_id, unsigned long num_ids, void (*read_func) (unsigned long, unsigned long, void *), void *dat); /* Checks for incoming packets */ void vapi_check (); --- peripheral/eth.c 2005-02-04 12:18:46.000000000 +0100 +++ ../or1ksim-ac/peripheral/eth.c 2005-02-04 14:29:29.000000000 +0100 @@ -54,7 +54,7 @@ /* simulator interface */ static void eth_reset_controller( struct eth_device *eth); -static void eth_vapi_read( unsigned long id, unsigned long data); +static void eth_vapi_read( unsigned long id, unsigned long data, void *dat); /* register interface */ static void eth_write32( oraddr_t addr, uint32_t value, void *dat ); static uint32_t eth_read32( oraddr_t addr, void *dat ); @@ -389,7 +389,7 @@ break; case ETH_RTX_VAPI: - break; + break; } break; @@ -644,7 +644,7 @@ /* Initialize VAPI */ if (config.ethernets.base_vapi_id) { eth->base_vapi_id = config.ethernets.base_vapi_id; - vapi_install_multi_handler( eth->base_vapi_id, ETH_NUM_VAPI_IDS, eth_vapi_read ); + vapi_install_multi_handler( eth->base_vapi_id, ETH_NUM_VAPI_IDS, eth_vapi_read, NULL ); } } } @@ -816,7 +816,7 @@ /* * VAPI connection to outside */ -static void eth_vapi_read (unsigned long id, unsigned long data) +static void eth_vapi_read (unsigned long id, unsigned long data, void *dat) { unsigned long which; struct eth_device *eth = eth_find_vapi_device( id, &which ); --- peripheral/gpio.c 2005-02-04 12:18:46.000000000 +0100 +++ ../or1ksim-ac/peripheral/gpio.c 2005-02-04 14:30:24.000000000 +0100 @@ -37,7 +37,7 @@ static struct gpio_device gpios[MAX_GPIOS]; -static void gpio_vapi_read( unsigned long id, unsigned long data ); +static void gpio_vapi_read( unsigned long id, unsigned long data, void *dat ); static uint32_t gpio_read32( oraddr_t addr, void *dat ); static void gpio_write32( oraddr_t addr, uint32_t value, void *dat ); @@ -73,7 +73,7 @@ /* Possibly connect to VAPI */ if ( config.gpios.base_vapi_id ) { gpio->base_vapi_id = config.gpios.base_vapi_id; - vapi_install_multi_handler( gpio->base_vapi_id, GPIO_NUM_VAPI_IDS, gpio_vapi_read ); + vapi_install_multi_handler( gpio->base_vapi_id, GPIO_NUM_VAPI_IDS, gpio_vapi_read, NULL ); } } } @@ -189,7 +189,7 @@ /* Input from "outside world" */ -void gpio_vapi_read( unsigned long id, unsigned long data ) +void gpio_vapi_read( unsigned long id, unsigned long data, void *dat ) { unsigned which; struct gpio_device *gpio = gpio_find_vapi_device( id, &which --- peripheral/16450.c 2005-02-04 12:18:46.000000000 +0100 +++ ../or1ksim-test/peripheral/16450.c 2005-02-04 14:47:43.000000000 +0100 @@ -238,7 +238,7 @@ } /* Function that handles incoming VAPI data. */ -void uart_vapi_read (unsigned long id, unsigned long data) +void uart_vapi_read (unsigned long id, unsigned long data, void *dat) { int uart; debug(4, "UART: id %08lx, data %08lx\n", id, data); @@ -589,7 +589,7 @@ fprintf (stderr, "ERROR: Wrong vapi_id (0x%lx) for uart %i, last byte is required to be %02x; ignoring.\n", config.uarts.vapi_id, i, i); config.uarts.vapi_id = 0; } else { - vapi_install_handler (config.uarts.vapi_id, uart_vapi_read); + vapi_install_handler (config.uarts.vapi_id, uart_vapi_read, NULL); register_memoryarea(config.uarts.baseaddr, UART_ADDR_SPACE, 1, 0, uart_read_byte, uart_write_byte, NULL); } } else if (config.uarts.channel[0]) { /* MM: Try to create stream. */ |
|||
1/1

