source: soft/giet_vm/giet_drivers/nic_driver.c @ 263

Last change on this file since 263 was 258, checked in by alain, 11 years ago

This is a major release, including a deep restructuration of code.
The main evolutions are

  • use of the Tsar preloader to load the GIET boot-loader from disk
  • introduction of a FAT32 file system library,
  • use of this fat32 library by the boot-loader to load the map.bin data structure, and the various .elf files
  • reorganisation of drivers (one file per peripheral).
  • introduction of drivers for new peripherals: vci_chbuf_dma and vci_multi_ahci.
  • introduction of a new physical memory allocator in the boot code.

This release has been tested on the tsar_generic_iob architecture,
for the two following mappings: 4c_1p_iob_four.xml and 4c_1p_iob_sort.xml

File size: 4.5 KB
RevLine 
[258]1///////////////////////////////////////////////////////////////////////////////////
2// File     : nic_driver.c
3// Date     : 23/05/2013
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7// The nic_driver.c and nic_driver.h files are part ot the GIET-VM nano-kernel.
8// This driver supports the vci_multi_nic component.
9//
10// It can exist only one network controller in the architecture, but this
11// component supports several channels.
12//
13// It can be accessed directly by software with memcpy(),
14// or it can be accessed through the vci_chbuf_dma component:
15// 
16// The '_nic_sync_write' and '_nic_sync_read' functions use a memcpy strategy to
17// implement the transfer between a data buffer (user space) and the NIC
18// buffer (kernel space). They are blocking until completion of the transfer.
19//
20// The _nic_cma_*_init() and _nic_cma_stop() functions use the VciChbufDma component
21// to transfer a flow of packets from the NIC RX hard chbuf (two containers)
22// to an user RX chbuf (two containers), and to transfer another flow of packets
23// from an user TX chbuf (two containers) to the NIC TX chbuf (two containers).
24// One NIC channel and two CMA channels must be allocated to the task
25// in the mapping_info data structure.
26//////////////////////////////////////////////////////////////////////////////////
27
28#include <giet_config.h>
29#include <nic_driver.h>
30#include <utils.h>
31
32#if !defined(GIET_USE_IOMMU)
33# error: You must define GIET_USE_IOMMU in the giet_config.h file
34#endif
35
36#if !defined(NB_NIC_CHANNELS)
37# error: You must define NB_NIC_CHANNELS in the hard_config.h file
38#endif
39
40#if ( NB_NIC_CHANNELS > 8 )
41# error: NB_NIC_CHANNELS cannot be larger than 8
42#endif
43
44#if !defined(NB_CMA_CHANNELS)
45# error: You must define NB_CMA_CHANNELS in the hard_config.h file
46#endif
47
48#if ( NB_CMA_CHANNELS > 8 )
49# error: NB_CMA_CHANNELS cannot be larger than 8
50#endif
51
52#if !defined( USE_IOB )
53# error: You must define USE_IOB in the hard_config.h file
54#endif
55
56#define in_unckdata __attribute__((section (".unckdata")))
57
58//////////////////////////////////////////////////////////////////////////////////
59// _nic_sync_write()
60// Transfer data from an memory buffer to the NIC device using a memcpy.
61// - buffer : base address of the memory buffer.
62// - length : number of bytes to be transfered.
63//////////////////////////////////////////////////////////////////////////////////
64unsigned int _nic_sync_write( const void*    buffer,
65                              unsigned int   length ) 
66{
67    _puts("[GIET ERROR] _nic_sync_write function not implemented\n");
68    _exit();
69
70    // unsigned char* nic_address = (unsigned char *) &seg_nic_base;
71    // memcpy((void *) nic_address, (void *) buffer, length);
72    return 0;
73}
74//////////////////////////////////////////////////////////////////////////////////
75// _nic_sync_read()
76// Transfer data from the NIC device to a memory buffer using a memcpy.
77// - buffer : base address of the memory buffer.
78// - length : number of bytes to be transfered.
79//////////////////////////////////////////////////////////////////////////////////
80unsigned int _nic_sync_read( const void*    buffer, 
81                             unsigned int   length ) 
82{
83    _puts("[GIET ERROR] _nic_sync_read function not implemented\n");
84    _exit();
85
86    // unsigned char* nic_address = (unsigned char *) &seg_nic_base;
87    // memcpy((void *) buffer, (void *) nic_address, length);
88    return 0;
89}
90//////////////////////////////////////////////////////////////////////////////////
91// _nic_cma_start()
92// Returns 0 if success, > 0 if error.
93//////////////////////////////////////////////////////////////////////////////////
94unsigned int _nic_cma_start( )
95{
96    _puts("[GIET ERROR] _nic_cma_start function not implemented\n");
97    _exit();
98
99    // unsigned char* nic_address = (unsigned char *) &seg_nic_base;
100    return 0;
101}
102//////////////////////////////////////////////////////////////////////////////////
103// _nic_cma_stop()
104// Returns 0 if success, > 0 if error.
105//////////////////////////////////////////////////////////////////////////////////
106unsigned int _nic_cma_stop()
107{
108    _puts("[GIET ERROR] _nic_cma_stop function not implemented\n");
109    _exit();
110
111    // unsigned char* nic_address = (unsigned char *) &seg_nic_base;
112    return 0;
113}
114
115
116// Local Variables:
117// tab-width: 4
118// c-basic-offset: 4
119// c-file-offsets:((innamespace . 0)(inline-open . 0))
120// indent-tabs-mode: nil
121// End:
122// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
123
Note: See TracBrowser for help on using the repository browser.