47 | | {{{ |
48 | | #include "soclib/block_device.h" |
49 | | |
50 | | static const void* bd_base = 0xc0000000; |
51 | | |
52 | | |
53 | | int block_read( const size_t lba, void *buffer, const size_t len ) |
54 | | { |
55 | | soclib_io_set(bd_base, BLOCK_DEVICE_LBA, lba); |
56 | | soclib_io_set(bd_base, BLOCK_DEVICE_BUFFER, (uint32_t)buffer); |
57 | | soclib_io_set(bd_base, BLOCK_DEVICE_COUNT, len); |
58 | | soclib_io_set(bd_base, BLOCK_DEVICE_OP, BLOCK_DEVICE_READ); |
59 | | while (soclib_io_get(bd_base, BLOCK_DEVICE_OP)) |
60 | | ; |
61 | | return soclib_io_get(bd_base, BLOCK_DEVICE_STATUS); |
62 | | } |
63 | | |
64 | | int block_write( const size_t lba, const void *buffer, const size_t len ) |
65 | | { |
66 | | soclib_io_set(bd_base, BLOCK_DEVICE_LBA, lba); |
67 | | soclib_io_set(bd_base, BLOCK_DEVICE_BUFFER, (uint32_t)buffer); |
68 | | soclib_io_set(bd_base, BLOCK_DEVICE_COUNT, len); |
69 | | soclib_io_set(bd_base, BLOCK_DEVICE_OP, BLOCK_DEVICE_WRITE); |
70 | | while (soclib_io_get(bd_base, BLOCK_DEVICE_OP)) |
71 | | ; |
72 | | return soclib_io_get(bd_base, BLOCK_DEVICE_STATUS); |
73 | | } |
74 | | |
75 | | uint32_t block_size() |
76 | | { |
77 | | return soclib_io_get(bd_base, BLOCK_DEVICE_SIZE); |
78 | | } |
79 | | |
80 | | }}} |
| 53 | Please see reference implementation in source:trunk/soclib/soclib/platform/topcells/caba-vgmn-block_device-mips32el |