static void dv_core_finish (struct hw *me) { set_hw_attach_address (me, dv_core_attach_address_callback); set_hw_dma_write_buffer (me, dv_core_dma_write_buffer_callback); set_hw_dma_read_buffer (me, dv_core_dma_read_buffer_callback); }
static void bfin_uart_finish (struct hw *me) { struct bfin_uart *uart; uart = HW_ZALLOC (me, struct bfin_uart); set_hw_data (me, uart); set_hw_io_read_buffer (me, bfin_uart_io_read_buffer); set_hw_io_write_buffer (me, bfin_uart_io_write_buffer); set_hw_dma_read_buffer (me, bfin_uart_dma_read_buffer); set_hw_dma_write_buffer (me, bfin_uart_dma_write_buffer); set_hw_ports (me, bfin_uart_ports); attach_bfin_uart_regs (me, uart); /* Initialize the UART. */ uart->dll = 0x0001; uart->lsr = 0x0060; }
static void bfin_spi_finish (struct hw *me) { struct bfin_spi *spi; spi = HW_ZALLOC (me, struct bfin_spi); set_hw_data (me, spi); set_hw_io_read_buffer (me, bfin_spi_io_read_buffer); set_hw_io_write_buffer (me, bfin_spi_io_write_buffer); set_hw_dma_read_buffer (me, bfin_spi_dma_read_buffer); set_hw_dma_write_buffer (me, bfin_spi_dma_write_buffer); set_hw_ports (me, bfin_spi_ports); attach_bfin_spi_regs (me, spi); /* Initialize the SPI. */ spi->ctl = 0x0400; spi->flg = 0xFF00; spi->stat = 0x0001; }
static void bfin_ppi_finish (struct hw *me) { struct bfin_ppi *ppi; const char *color; ppi = HW_ZALLOC (me, struct bfin_ppi); set_hw_data (me, ppi); set_hw_io_read_buffer (me, bfin_ppi_io_read_buffer); set_hw_io_write_buffer (me, bfin_ppi_io_write_buffer); set_hw_dma_read_buffer (me, bfin_ppi_dma_read_buffer); set_hw_dma_write_buffer (me, bfin_ppi_dma_write_buffer); set_hw_ports (me, bfin_ppi_ports); attach_bfin_ppi_regs (me, ppi); /* Initialize the PPI. */ if (hw_find_property (me, "color")) color = hw_find_string_property (me, "color"); else color = NULL; ppi->color = bfin_gui_color (color); }
struct hw * hw_create (struct sim_state *sd, struct hw *parent, const char *family, const char *name, const char *unit, const char *args) { /* NOTE: HW must be allocated using ZALLOC, others use HW_ZALLOC */ struct hw *hw = ZALLOC (struct hw); /* our identity */ hw->family_of_hw = hw_strdup (hw, family); hw->name_of_hw = hw_strdup (hw, name); hw->args_of_hw = hw_strdup (hw, args); /* a hook into the system */ if (sd != NULL) hw->system_of_hw = sd; else if (parent != NULL) hw->system_of_hw = hw_system (parent); else hw_abort (parent, "No system found"); /* in a tree */ if (parent != NULL) { struct hw **sibling = &parent->child_of_hw; while ((*sibling) != NULL) sibling = &(*sibling)->sibling_of_hw; *sibling = hw; hw->parent_of_hw = parent; } /* top of tree */ if (parent != NULL) { struct hw *root = parent; while (root->parent_of_hw != NULL) root = root->parent_of_hw; hw->root_of_hw = root; } /* a unique identifier for the device on the parents bus */ if (parent != NULL) { hw_unit_decode (parent, unit, &hw->unit_address_of_hw); } /* Determine our path */ if (parent != NULL) hw->path_of_hw = full_name_of_hw (hw, NULL, 0); else hw->path_of_hw = "/"; /* create our base type */ hw->base_of_hw = HW_ZALLOC (hw, struct hw_base_data); hw->base_of_hw->finished_p = 0; /* our callbacks */ set_hw_io_read_buffer (hw, panic_hw_io_read_buffer); set_hw_io_write_buffer (hw, panic_hw_io_write_buffer); set_hw_dma_read_buffer (hw, passthrough_hw_dma_read_buffer); set_hw_dma_write_buffer (hw, passthrough_hw_dma_write_buffer); set_hw_unit_decode (hw, generic_hw_unit_decode); set_hw_unit_encode (hw, generic_hw_unit_encode); set_hw_unit_address_to_attach_address (hw, generic_hw_unit_address_to_attach_address); set_hw_unit_size_to_attach_size (hw, generic_hw_unit_size_to_attach_size); set_hw_attach_address (hw, passthrough_hw_attach_address); set_hw_detach_address (hw, passthrough_hw_detach_address); set_hw_delete (hw, ignore_hw_delete); /* locate a descriptor */ { const struct hw_descriptor **table; for (table = hw_descriptors; *table != NULL; table++) { const struct hw_descriptor *entry; for (entry = *table; entry->family != NULL; entry++) { if (strcmp (family, entry->family) == 0) { hw->base_of_hw->descriptor = entry; break; } } } if (hw->base_of_hw->descriptor == NULL) { hw_abort (parent, "Unknown device `%s'", family); } } /* Attach dummy ports */ create_hw_alloc_data (hw); create_hw_property_data (hw); create_hw_port_data (hw); create_hw_event_data (hw); create_hw_handle_data (hw); create_hw_instance_data (hw); return hw; }