Exemplo n.º 1
0
void _vbuf_init(int nBuf) 
{
    int i;
    VBUF *vbuf;
    
    //vbuf = (VBUF*)dataAddr;
    vbuf = (VBUF*)A_ALLOCRAM(VBUF_SIZE);
    vbuf->next_buf = NULL;
    vbuf->desc_list = NULL;
                    
    g_vbufCtx.free_buf_head = vbuf;
    
    for(i=1; i<nBuf; i++)
    {
        //vbuf = (VBUF*)(dataAddr + i*VBUF_SIZE);
        vbuf = (VBUF*)A_ALLOCRAM(VBUF_SIZE);
        
        vbuf->desc_list = NULL;
        vbuf->next_buf = g_vbufCtx.free_buf_head;
        g_vbufCtx.free_buf_head = vbuf;
    }    
    
    g_vbufCtx.nVbufNum = nBuf;
    //return (dataAddr + nBuf*VBUF_SIZE);
    return;
}
Exemplo n.º 2
0
/**
 * @brief Allocates a DMA region, uses the tag elem to store the
 *        tag value which constant for all the mappings done
 *        through this API.
 * 
 * @param osdev
 * @param size
 * @param coherent
 * @param dmap
 * 
 * @return void* (Virtual address)
 */
inline void*
__adf_os_dmamem_alloc(__adf_os_device_t osdev, adf_os_size_t size, 
                      a_bool_t coherent, __adf_os_dma_map_t *dmap)
{    
    (*dmap) = A_ALLOCRAM(sizeof(struct __adf_dma_map));
    
	if((*dmap) == NULL){
		goto fail_malloc;
	}
	    
    (*dmap)->ds_addr = A_ALLOCRAM(size);
    (*dmap)->ds_len = size;
    
    return (*dmap)->ds_addr;
    
fail_malloc: 
    return NULL;            
}
Exemplo n.º 3
0
LOCAL void console_mod_init(CONSOLE_CONFIG *config)
{
    UART_HW_CONFIG  uart_config;
    void            *phys_port;
    int             i;
    
    if (Console_info != NULL) {
        return;    
    }
    
    Console_info = (CONSOLE_INFO *)A_ALLOCRAM(sizeof(CONSOLE_INFO));
    
    if (config != NULL) {    
        Console_info->config = *config;
    }
    
    if (0 == Console_info->config.max_cmdline_length) {
        Console_info->config.max_cmdline_length = CONSOLE_DEF_MAX_LINE_CHARS;   
    }    
    if (0 == Console_info->config.max_history) {
        Console_info->config.max_history = CONSOLE_DEF_MAX_HISTORY;    
    }    
    if (0 == Console_info->config.phys_uart_id) {
        Console_info->config.phys_uart_id = UART_SERP_UART0_INSTANCE_ID;
        if (NULL == Console_info->config.logical_port_name) {
            Console_info->config.logical_port_name = (A_CHAR *)UART_PORT0_NAME;
        }        
        if (0 == Console_info->config.baud) {
            Console_info->config.baud = HOST_INTEREST->hi_desired_baud_rate;    
        }
    }    
    if (0 == Console_info->config.baud) {
        Console_info->config.baud = CONSOLE_DEF_BAUDRATE;      
    } 
    if (0 == Console_info->config.max_argv_len) {
        Console_info->config.max_argv_len = CONSOLE_DEF_MAX_ARGV_LENGTH;    
    }
    if (0 == Console_info->config.output_buffer_size) {
        Console_info->config.output_buffer_size = CONSOLE_TRANSMIT_BUFFER_SIZE;    
    }   
    if (0 == Console_info->config.idle_timeout_ms) {
        Console_info->config.idle_timeout_ms = CONSOLE_RECV_IDLE_TIMEOUT_MS;
    }
    
    Console_info->history_length = Console_info->config.max_cmdline_length + 1;   
    Console_info->history_buffer = (A_CHAR *)A_ALLOCRAM(Console_info->history_length * 
                                                        Console_info->config.max_history);   
    Console_info->current_line = (A_CHAR *)A_ALLOCRAM(Console_info->config.max_cmdline_length + 1);
    
    for (i = 0; i < CONSOLE_DEF_MAX_ARGC; i++) {
        Console_info->argv_buffers[i] = (A_CHAR *)A_ALLOCRAM(Console_info->config.max_argv_len + 1);
    }
    
        /* setup the physical modem */
    phys_port = UARTSERP_HW_Init(Console_info->config.phys_uart_id);
    A_ASSERT(phys_port != NULL);  
    A_MEMZERO(&uart_config,sizeof(uart_config));        
        /* for the console, set UART buffering parameters
         * for recv we can use a fixed value to accommodate very fast typists */
    uart_config.RxBufferSize = CONSOLE_RECV_BUFFER_SIZE;
        /* use a value that is an override */
    uart_config.TxBufferSize = Console_info->config.output_buffer_size;
    UARTSERP_HW_Start(phys_port,&uart_config);
    
    A_INIT_TIMER(&Console_info->recv_idle_timer,
                 console_recv_idle_timeout,
                 NULL);
                 
    A_TIMER_SET_FLAGS(&Console_info->recv_idle_timer,TIMER_FLAGS_NO_FORCE_DISARM);  
}