Skip to content

Commit ffa565f

Browse files
committed
discover dldi allocated space
1 parent be26934 commit ffa565f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

dldi/source/dldi_header.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
.global word_params
77
.global words_msg
88
.global tmp_buf_addr
9+
.global allocated_space
910
.align 4
1011
.arm
1112

@@ -28,6 +29,7 @@
2829
.byte 0x01 @ Version number
2930
.byte 0x0d @ 8KiB @ Log [base-2] of the size of this driver in bytes.
3031
.byte FIX_GOT | FIX_BSS | FIX_GLUE | FIX_ALL @ Sections to fix
32+
allocated_space:
3133
.byte 0x00 @ Space allocated in the application, not important here.
3234

3335
@---------------------------------------------------------------------------------

dldi/source/iointerface.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ extern vu32 words_msg;
4646

4747
// Use the dldi remaining space as temporary buffer : 28k usually available
4848
extern vu32* tmp_buf_addr;
49+
extern vu8 allocated_space;
4950

5051
void sendValue32(u32 value32) {
5152
nocashMessage("sendValue32");
@@ -137,8 +138,7 @@ bool sd_ReadSectors(sec_t sector, sec_t numSectors,void* buffer) {
137138

138139
//__custom_mpu_setup();
139140

140-
//int max_reads = ((2 ^ io_dldi_data->allocatedSize) / 512) - 11;
141-
int max_reads = MAX_READ;
141+
int max_reads = ((1 << allocated_space) / 512) - 11;
142142

143143
for(int numreads =0; numreads<numSectors; numreads+=max_reads) {
144144
startsector = sector+numreads;
@@ -177,8 +177,7 @@ bool sd_WriteSectors(sec_t sector, sec_t numSectors,const void* buffer) {
177177

178178
//__custom_mpu_setup();
179179

180-
//int max_reads = ((2 ^ io_dldi_data->allocatedSize) / 512) - 11;
181-
int max_reads = MAX_READ;
180+
int max_reads = ((1 << allocated_space) / 512) - 11;
182181

183182
for(int numreads =0; numreads<numSectors; numreads+=max_reads) {
184183
startsector = sector+numreads;

0 commit comments

Comments
 (0)