Changeset 437 for soft/giet_vm/giet_drivers/bdv_driver.h
- Timestamp:
- Nov 3, 2014, 10:53:00 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/bdv_driver.h
r350 r437 5 5 // Maintainer: cesar fuguet 6 6 // Copyright (c) UPMC-LIP6 7 /////////////////////////////////////////////////////////////////////////////////// 8 // The bdv_driver.c and bdv_driver.h files are part ot the GIET-VM kernel. 9 // This driver supports the SocLib vci_block_device component, that is 10 // a single channel, block oriented, external storage contrÃŽler. 11 // 12 // The _bdv_read() and _bdv_write() functions are always blocking. 13 // They can be called in 3 modes: 14 // 15 // - In BOOT mode, these functions use a polling policy on the BDV STATUS 16 // register to detect transfer completion, as interrupts are not activated. 17 // This mode is used by the boot code to load the map.bin file into memory 18 // (before MMU activation), or to load the .elf files (after MMU activation). 19 // 20 // - In KERNEL mode, these functions use a descheduling strategy: 21 // The ISR executed when transfer completes should restart the calling task. 22 // There is no checking of user access right to the memory buffer. 23 // This mode must be used, for an "open" system call. 24 // 25 // - In USER mode, these functions use a descheduling strategy: 26 // The ISR executed when transfer completes should restart the calling task, 27 // The user access right to the memory buffer must be checked. 28 // This mode must be used for a "read/write" system call. 29 // 30 // As the BDV component can be used by several programs running in parallel, 31 // the _bdv_lock variable guaranties exclusive access to the device. The 32 // _bdv_read() and _bdv_write() functions use atomic LL/SC to get the lock. 33 // 34 // Finally, the memory buffer must fulfill the following conditions: 35 // - The buffer must be word aligned, 36 // - The buffer must be mapped in user space for an user access, 37 // - The buffer must be writable in case of (to_mem) access, 38 // - The total number of physical pages occupied by the user buffer cannot 39 // be larger than 512 pages if the IOMMU is activated, 40 // - All physical pages occupied by the user buffer must be contiguous 41 // if the IOMMU is not activated. 42 // An error code is returned if these conditions are not verified. 43 // 44 // The SEG_IOC_BASE address must be defined in the hard_config.h file. 7 45 /////////////////////////////////////////////////////////////////////////////////// 8 46 … … 56 94 57 95 /////////////////////////////////////////////////////////////////////////////////// 58 // BDV access functions (vci_block_device)96 // Access functions 59 97 /////////////////////////////////////////////////////////////////////////////////// 60 98 99 /////////////////////////////////////////////////////////////////////////////////// 100 // This function cheks block size == 512, and desactivates the interrupts. 101 // Return 0 for success, > 0 if error 102 /////////////////////////////////////////////////////////////////////////////////// 61 103 extern unsigned int _bdv_init(); 62 104 105 /////////////////////////////////////////////////////////////////////////////////// 106 // Transfer data from the block device to a memory buffer. 107 // - mode : BOOT / KERNEL / USER 108 // - lba : first block index on the block device 109 // - buffer : base address of the memory buffer (must be word aligned) 110 // - count : number of blocks to be transfered. 111 // Returns 0 if success, > 0 if error. 112 //////////////////////////////////////////////////////////////////////////////////// 113 extern unsigned int _bdv_read( unsigned int mode, 114 unsigned int lba, 115 unsigned long long buffer, 116 unsigned int count ); 117 118 /////////////////////////////////////////////////////////////////////////////////// 119 // Transfer data from a memory buffer to the block device. 120 // - mode : BOOT / KERNEL / USER 121 // - lba : first block index on the block device 122 // - buffer : base address of the memory buffer (must be word aligned) 123 // - count : number of blocks to be transfered. 124 // Returns 0 if success, > 0 if error. 125 /////////////////////////////////////////////////////////////////////////////////// 63 126 extern unsigned int _bdv_write( unsigned int mode, 64 127 unsigned int lba, … … 66 129 unsigned int count ); 67 130 68 extern unsigned int _bdv_read( unsigned int mode, 69 unsigned int lba, 70 unsigned long long buffer, 71 unsigned int count ); 72 131 /////////////////////////////////////////////////////////////////////////////////// 132 // Returns device status. 133 /////////////////////////////////////////////////////////////////////////////////// 73 134 extern unsigned int _bdv_get_status(); 74 135 136 /////////////////////////////////////////////////////////////////////////////////// 137 // Returns block size. 138 /////////////////////////////////////////////////////////////////////////////////// 75 139 extern unsigned int _bdv_get_block_size(); 76 140 141 /////////////////////////////////////////////////////////////////////////////////// 142 // This ISR save the status, acknowledge the IRQ, and activates the task 143 // waiting on IO transfer. It can be an HWI or a SWI. 144 // 145 // TODO the _set_task_slot access should be replaced by an atomic LL/SC 146 // when the CTX_RUN bool will be replaced by a bit_vector. 147 /////////////////////////////////////////////////////////////////////////////////// 77 148 extern void _bdv_isr( unsigned irq_type, 78 149 unsigned irq_id, 79 150 unsigned channel ); 80 151 81 ///////////////////////////////////////////////////////////////////////////////////82 152 83 153 #endif
Note: See TracChangeset
for help on using the changeset viewer.