/*=========================================================================== FUNCTION glink_init DESCRIPTION Initializes the GLink core library. ARGUMENTS None RETURN VALUE None SIDE EFFECTS None ===========================================================================*/ void glink_init(void) { uint32 i; glink_mem_log_cs = glink_os_cs_create(); glink_core_status = GLINK_INITIALIZED; /* Create/Initalize crtitical sections */ glink_transport_q_cs = glink_os_cs_create(); if(glink_transport_q_cs == NULL) { return; } glink_os_cs_acquire(glink_transport_q_cs); for(i= 0; i < sizeof(glink_registered_transports)/sizeof(smem_list_type); i++) { smem_list_init(&glink_registered_transports[i]); } glink_os_cs_release(glink_transport_q_cs); }
/*=========================================================================*/ glink_err_type xport_rpm_init(void *arg) { uint32 ind; glink_core_transport_cfg_type xport_rpm_cfg = { 0 }; uint32 *msg_ram_toc = (uint32*)xport_rpm_msg_ram_toc; xport_rpm_toc_entry_type *entry; uint32 msg_ram_toc_num; char* msg_ram_toc_entry_start = (char*)&msg_ram_toc[XPORT_RPM_TOC_ENTRIES_IDX]; dprintf(SPEW, "%s:%d: RPM Transport INIT\n", __func__, __LINE__); if (xport_rpm_config_num == 0) { return GLINK_STATUS_SUCCESS; } if (!xport_rpm_is_toc_present()) { /* switch to err fatal once RPM side is integrated */ dprintf(CRITICAL, "%s:%d: RPM Transport Failure: Invalid ToC cookie\n", __func__, __LINE__); return GLINK_STATUS_FAILURE; } msg_ram_toc_num = msg_ram_toc[XPORT_RPM_TOC_LENGTH_IDX]; if (msg_ram_toc_num == 0) { dprintf(SPEW, "%s:%d RPM Transport Success\n", __func__, __LINE__); return GLINK_STATUS_SUCCESS; } xport_rpm_ctx = glink_os_calloc(sizeof(*xport_rpm_ctx)*xport_rpm_config_num); if (xport_rpm_ctx == NULL) { dprintf(INFO, "%s:%d RPM Transport Failed to allocate context\n", __func__, __LINE__); ASSERT(0); } /* Initialize supported version and features */ xport_rpm_version.version = 1; xport_rpm_version.features = 0; xport_rpm_version.negotiate_features = &xport_rpm_negotiate_features; /* Initialize edges */ dprintf(SPEW, "%s:%d: Initialize Edges\n", __func__, __LINE__); for (ind = 0; ind < xport_rpm_config_num; ind++) { xport_rpm_ctx[ind].pcfg = xport_rpm_get_config(ind); /* Find FIFOs in MSG RAM ToC */ for (entry = (xport_rpm_toc_entry_type*)msg_ram_toc_entry_start; (char*)entry < msg_ram_toc_num*sizeof(*entry) + msg_ram_toc_entry_start && (xport_rpm_ctx[ind].tx_desc == NULL || xport_rpm_ctx[ind].rx_desc == NULL); entry++) { if (entry->fifo_id == xport_rpm_ctx[ind].pcfg->tx_fifo_id) { xport_rpm_ctx[ind].tx_desc = (xport_rpm_ind_type*)&xport_rpm_msg_ram[entry->fifo_offset]; xport_rpm_ctx[ind].tx_fifo = (char*)(xport_rpm_ctx[ind].tx_desc + 1); xport_rpm_ctx[ind].tx_fifo_size = entry->fifo_size; } else if (entry->fifo_id == xport_rpm_ctx[ind].pcfg->rx_fifo_id) { xport_rpm_ctx[ind].rx_desc =(xport_rpm_ind_type*)&xport_rpm_msg_ram[entry->fifo_offset]; xport_rpm_ctx[ind].rx_fifo = (char*)(xport_rpm_ctx[ind].rx_desc + 1); xport_rpm_ctx[ind].rx_fifo_size = entry->fifo_size; } } if (xport_rpm_ctx[ind].tx_desc == NULL || xport_rpm_ctx[ind].rx_desc == NULL) { /* FIFOs not found in MSG RAM ToC. */ xport_rpm_ctx[ind].pcfg = NULL; continue; } /* Rx read index should be cleared last */ xport_rpm_ctx[ind].tx_desc->write_ind = 0; xport_rpm_ctx[ind].rx_desc->read_ind = 0; /* Initialize context */ xport_rpm_ctx[ind].tx_link_lock = glink_os_cs_create(); xport_rpm_ctx[ind].rx_link_lock = glink_os_cs_create(); /* Initialize GLink transport interface */ xport_rpm_ctx[ind].xport_if.tx_cmd_version = &xport_rpm_tx_cmd_version; xport_rpm_ctx[ind].xport_if.tx_cmd_version_ack = &xport_rpm_tx_cmd_version_ack; xport_rpm_ctx[ind].xport_if.set_version = &xport_rpm_set_version; xport_rpm_ctx[ind].xport_if.tx_cmd_ch_open = &xport_rpm_tx_cmd_ch_open; xport_rpm_ctx[ind].xport_if.tx_cmd_ch_close = &xport_rpm_tx_cmd_ch_close; xport_rpm_ctx[ind].xport_if.tx_cmd_ch_remote_open_ack = &xport_rpm_tx_cmd_ch_remote_open_ack; xport_rpm_ctx[ind].xport_if.tx_cmd_ch_remote_close_ack = &xport_rpm_tx_cmd_ch_remote_close_ack; xport_rpm_ctx[ind].xport_if.tx = &xport_rpm_tx; xport_rpm_ctx[ind].xport_if.tx_cmd_set_sigs = &xport_rpm_tx_cmd_set_sigs; xport_rpm_ctx[ind].xport_if.ssr = &xport_rpm_ssr; xport_rpm_ctx[ind].xport_if.mask_rx_irq = &xport_rpm_mask_interrupt; xport_rpm_ctx[ind].xport_if.poll = (poll_fn)&xport_rpm_isr; xport_rpm_ctx[ind].xport_if.wait_link_down = &xport_rpm_wait_link_down; /* TODO: glink transport priority */ xport_rpm_ctx[ind].xport_if.glink_priority = GLINK_XPORT_RPM; /* Setup GLink configuration */ xport_rpm_cfg.name = XPORT_RPM_NAME; xport_rpm_cfg.remote_ss = xport_rpm_ctx[ind].pcfg->remote_ss; xport_rpm_cfg.version = &xport_rpm_version; xport_rpm_cfg.version_count = 1; xport_rpm_cfg.max_cid = 0xFF; xport_rpm_cfg.max_iid = 0; if (glink_core_register_transport(&xport_rpm_ctx[ind].xport_if, &xport_rpm_cfg) != GLINK_STATUS_SUCCESS) { /* Registration failed, set index to invalid. */ xport_rpm_ctx[ind].pcfg = NULL; continue; } if ( !glink_os_register_isr( xport_rpm_ctx[ind].pcfg->irq_in, (os_isr_cb_fn)xport_rpm_isr, &xport_rpm_ctx[ind]) ) { /* ISR registration failed, set index to invalid. * It will never fail */ xport_rpm_ctx[ind].pcfg = NULL; continue; } /* send link up notification */ xport_rpm_ctx[ind].xport_if.glink_core_if_ptr->link_up((glink_transport_if_type *)&xport_rpm_ctx[ind].xport_if); } return GLINK_STATUS_SUCCESS; }