DeviceFS fix
Colin (478) 2433 posts |
As suggested in another post I’m posting these changes which will fix specialfield In DeviceFS.c.Special to fix special fields not being set. In ScanSpecial
In DeviceFS.c.FSystem to fix noblock In open_input
in open_output 20 ADD r6, r6, #1 STR r6, [pr, #parent_UsedOutputs] ; store a modified input counter [ {TRUE} ; COLIN_NOBLOCK_FIX LDR r3, [fr, #file_Flags] ORR r3, r3, #ff_FileForTX :OR: ff_ModifiedCounters ; being used for TX | MOV r3, #ff_FileForTX :OR: ff_ModifiedCounters ; being used for TX ] STR r3, [fr, #file_Flags] ; stash some important flags Debug open, "file flags", r3 in HandleSpecial 10 LDR r0, sp_block ; maybe set the non-blocking bit TEQ r0, #1 LDR r0, [fr, #file_Flags] [ {TRUE} ;COLIN_NOBLOCK_FIX ORREQ r0, r0, #ff_NonBlocking BICNE r0, r0, #ff_NonBlocking | ORRNE r0, r0, #ff_NonBlocking BICEQ r0, r0, #ff_NonBlocking ] STR r0, [fr, #file_Flags] [ TWSleep |
Sprow (202) 1155 posts |
I can see what the last 3 patches are doing but LDR r0,[sp,#CallerR0] ; reset to beginning of scanned string might need a bit of explaining. As I read it, R5 is a copy of the start of the validation string template, this is reset into R1 for each attempted keyword match with the input string (in R0). For no match, don’t you only want to rewind the validation string, not the input string too? |
Colin (478) 2433 posts |
R1 is changed elsewhere. It points to the start of the keyword. The keywords are stepped through and used to search for a match in the special string. Specialstringfix.zip contains a test program for ScanSpecial which can demonstrate the affects of the change – see the readme file. Edit: not sure if that explains it any better but basically the algorithm tries to be i=0 foreach keyword in validation_string { value[i++]=getvalue(keyword,specialstring); // if keyword not found value[i]=0xdeaddead } and specialstring is not being reset every loop |
Sprow (202) 1155 posts |
Right – I see now there’s another loop further out. So for each keyword in validation_string it looked through the special field, but in the no match case never went back to the start – only ever forwards. I was concerned that by resetting R0 there was an infinite loop. brown/Nfox/N fox123;brown456; would only match “brown”, and not go back to look for “fox”. |
Colin (478) 2433 posts |
Your version of the fix you’ve put in FSystem for noblock is wrong. You changed the validation string instead of the code. The side effect of this is that now that the noblock flag is taken notice of a 0xdeaddead flag will result in nonblocking by default and existing devices will expect blocking by default. |
Sprow (202) 1155 posts |
The “nosleep,sleep” flag had a local precedent so it seemed sensible to follow it, given the variable names the original author chose. It looks right
but I see that would not block by default. I’ll swap it round… |
Colin (478) 2433 posts |
Darn you’ve got me in my pedantic mode now. For me the local precedence is that the first item in a switch is the same as the default. Anyway it will work thanks. |