Changeset 437 for soft/giet_vm/giet_drivers/rdk_driver.c
- Timestamp:
- Nov 3, 2014, 10:53:00 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/rdk_driver.c
r405 r437 6 6 // Copyright (c) UPMC-LIP6 7 7 /////////////////////////////////////////////////////////////////////////////////// 8 // The rdk_driver.c and rdk_driver.h files are part ot the GIET-VM kernel.9 //10 // This driver supports a virtual disk implemented as a memory segment,11 // in the address space.12 //13 // The _rdk_read() and _rdk_write() blocking functions use a software memcpy,14 // whatever the selected mode. They return only when the transfer is completed.15 // As the number of concurrent accesses is not bounded, these functions16 // don't use the _ioc_lock variable.17 //18 // The SEG_RDK_BASE virtual address must be defined in the hard_config.h19 // file when the USE_RAMDISK flag is set.20 ///////////////////////////////////////////////////////////////////////////////////21 8 22 9 #include <giet_config.h> … … 24 11 #include <rdk_driver.h> 25 12 #include <utils.h> 26 #include <tty_driver.h>27 #include <ctx_handler.h>28 13 29 14 #if !defined(SEG_RDK_BASE) … … 31 16 #endif 32 17 33 /////////////////////////////////////////////////////////////////////////////// 34 // _rdk_init() 35 // This function does nothing, and return 0 for success. 36 /////////////////////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////// 37 19 unsigned int _rdk_init( unsigned int channel ) 38 20 { … … 40 22 } 41 23 42 /////////////////////////////////////////////////////////////////////////////// 43 // _rdk_read() 44 // Transfer data from the RAMDISK to a memory buffer. 45 // - mode : BOOT / KERNEL / USER 46 // - lba : first block index on the block device 47 // - buffer : virtual base address of the memory buffer 48 // - count : number of blocks to be transfered. 49 // Returns 0 if success, > 0 if error. 50 /////////////////////////////////////////////////////////////////////////////// 24 ////////////////////////////////////////// 51 25 unsigned int _rdk_read( unsigned int lba, 52 26 unsigned int buffer, 53 27 unsigned int count) 54 28 { 29 #if USE_IOC_RDK 55 30 56 31 #if GIET_DEBUG_IOC_DRIVER 57 _printf("\n[IOC DEBUG] Enter _rdk_read() at cycle %d" 58 "\n - vaddr = %x" 59 "\n - sectors = %d" 60 "\n - lba = %x", 61 _get_proctime(), buffer, count, lba ); 32 _puts("\n[IOC DEBUG] Enter _rdk_read() at cycle "); 33 _putd( _get_proctime() ); 34 _puts("\n - vaddr = "); 35 _putx( buffer ); 36 -puts("\n - sectors = "); 37 _putd( count ); 38 -puts("\n - lba = "); 39 _putx( lba ); 40 _puts("\n"); 62 41 #endif 63 42 64 #if USE_IOC_RDK65 43 char* src = (char*)SEG_RDK_BASE + (512*lba); 66 44 char* dst = (char*)buffer; 67 45 memcpy( dst, src, count*512 ); 68 46 return 0; 47 69 48 #else 70 _printf("[GIET ERROR] _rdk_read() should not be used if USE_IOC_RDK not set\n"); 49 50 _puts("[GIET ERROR] _rdk_read() should not be used if USE_IOC_RDK not set\n"); 71 51 return 1; 52 72 53 #endif 73 54 } 74 55 75 /////////////////////////////////////////////////////////////////////////////// 76 // _rdk_write() 77 // Transfer data from a memory buffer to the block device. 78 // - mode : BOOT / KERNEL / USER 79 // - lba : first block index on the block device 80 // - buffer : virtual base address of the memory buffer 81 // - count : number of blocks to be transfered. 82 // Returns 0 if success, > 0 if error. 83 /////////////////////////////////////////////////////////////////////////////// 56 ////////////////////////////////////////// 84 57 unsigned int _rdk_write( unsigned int lba, 85 58 unsigned int buffer, 86 59 unsigned int count ) 87 60 { 61 #if USE_IOC_RDK 88 62 89 63 #if GIET_DEBUG_IOC_DRIVER 90 _printf("\n[IOC DEBUG] Enter _rdk_write() at cycle %d" 91 "\n - vaddr = %x" 92 "\n - sectors = %d" 93 "\n - lba = %x", 94 _get_proctime(), buffer, count, lba ); 64 _puts("\n[IOC DEBUG] Enter _rdk_write() at cycle "); 65 _putd( _get_proctime() ); 66 _puts("\n - vaddr = "); 67 _putx( buffer ); 68 -puts("\n - sectors = "); 69 _putd( count ); 70 -puts("\n - lba = "); 71 _putx( lba ); 72 _puts("\n"); 95 73 #endif 96 74 97 #if USE_IOC_RDK98 75 char* dst = (char*)SEG_RDK_BASE + (512*lba); 99 76 char* src = (char*)buffer; 100 77 memcpy( dst, src, count*512 ); 101 78 return 0; 79 102 80 #else 103 _printf("[GIET ERROR] _rdk_write() should not be used if USE_IOC_RDK not set\n"); 81 82 _puts("[GIET ERROR] _rdk_write() should not be used if USE_IOC_RDK not set\n"); 104 83 return 1; 84 105 85 #endif 106 86 } 107 87 108 /////////////////////////////////////////////////////////////////////////////// 109 // _rdk_get_block_size() 110 // This function returns the block_size. 111 /////////////////////////////////////////////////////////////////////////////// 88 ////////////////////////////////// 112 89 unsigned int _rdk_get_block_size() 113 90 { 114 91 return 512; 92 } 93 94 ////////////////////////////// 95 unsigned int _rdk_get_status() 96 { 97 return 0; 115 98 } 116 99
Note: See TracChangeset
for help on using the changeset viewer.