📄 f34x_msd_sect_serv.src
字号:
LCALL L?0048
MOV R3,#01H
MOV R2,#HIGH (Scratch)
MOV R1,#LOW (Scratch)
LCALL _MMC_FLASH_Block_Read
MOV DPTR,#error?443
MOV A,R6
MOVX @DPTR,A
INC DPTR
MOV A,R7
MOVX @DPTR,A
ORL A,R6
JZ ?C0017
; if(!++loopguard) {
; SOURCE LINE # 213
INC DPTR
MOVX A,@DPTR
INC A
MOVX @DPTR,A
JNZ ?C0016
; printf("Unable to Read sector %ld" ENDLINE , sector);
; SOURCE LINE # 214
MOV R3,#0FFH
MOV R2,#HIGH (?SC_68)
MOV R1,#LOW (?SC_68)
MOV DPTR,#sector?442
LCALL L?0048
MOV DPTR,#?_printf?BYTE+03H
LCALL ?C?LSTXDATA
LCALL _printf
; break;
; SOURCE LINE # 215
; }
; SOURCE LINE # 216
?C0017:
; #ifdef __F340_VER__
; } else {
; error = Read_Sector(sector,Scratch);
; }
; #endif
; return error;
; SOURCE LINE # 222
MOV DPTR,#error?443
MOVX A,@DPTR
MOV R6,A
INC DPTR
MOVX A,@DPTR
MOV R7,A
; }
; SOURCE LINE # 223
?C0019:
RET
; END OF _Sect_Read
;
; //----------------------------------------------------------------------------
; // Sect_Write
; //----------------------------------------------------------------------------
; //
; // It writes one sector from Scratch buffer
; //
; // Parameters : sector - sector's number
; // Return Value :
; //----------------------------------------------------------------------------
;
; void Sect_Write(unsigned long sector)
RSEG ?PR?_Sect_Write?F34X_MSD_SECT_SERV
_Sect_Write:
USING 0
; SOURCE LINE # 235
MOV DPTR,#sector?545
LCALL ?C?LSTXDATA
; {
; SOURCE LINE # 236
; int xdata error;
; #ifdef __F340_VER__
; if(!Is_Compact_Flash) {
; #endif
; MMC_FLASH_Block_Write(sector+HIDDEN_SECTORS,Scratch); // wozb - 27-09-2005 instead of this write data from uart
; SOURCE LINE # 241
MOV DPTR,#sector?545
LCALL L?0048
MOV R3,#01H
MOV R2,#HIGH (Scratch)
MOV R1,#LOW (Scratch)
LCALL _MMC_FLASH_Block_Write
; #ifdef __F340_VER__
; } else {
; error = Write_Sector(sector,Scratch);
; }
; #endif
; // After reformatting by the PC, we must re-init the sector server.
; if(sector==0) {
; SOURCE LINE # 248
CLR A
MOV R7,A
MOV R6,A
MOV R5,A
MOV R4,A
MOV DPTR,#sector?545
LCALL L?0045
JNZ ?C0021
; Sect_Validate();
; SOURCE LINE # 249
LCALL _?Sect_Validate
; }
; SOURCE LINE # 250
; }
; SOURCE LINE # 251
?C0021:
RET
; END OF _Sect_Write
;
; //----------------------------------------------------------------------------
; // Sect_Write_Multi_Fat
; //----------------------------------------------------------------------------
; //
; // Automatically handle multiple FAT copies
; //
; // Parameters : sector - sector's number
; // Return Value :
; //----------------------------------------------------------------------------
;
; void Sect_Write_Multi_Fat(unsigned long sector)
RSEG ?PR?_Sect_Write_Multi_Fat?F34X_MSD_SECT_SERV
_Sect_Write_Multi_Fat:
USING 0
; SOURCE LINE # 263
LCALL L?0056
; {
; SOURCE LINE # 264
; if(sector<Sect_Fat1() || sector>=Sect_Root_Dir()) {
; SOURCE LINE # 265
LCALL Sect_Fat1
LCALL L?0043
JC ?C0023
LCALL Sect_Root_Dir
LCALL L?0043
JC ?C0025
?C0023:
; // This is a 'normal' block, not in the FAT:
; Sect_Write(sector);
; SOURCE LINE # 267
LCALL L?0046
LJMP _Sect_Write
; } else {
; SOURCE LINE # 268
?C0025:
; // Writing to one of the FAT's will automagically write the same block to the
; // other FAT copies.
; while(sector>=Sect_Fat2()) // Decrement 'sector' to refer to 1st FAT copy.
; SOURCE LINE # 271
LCALL Sect_Fat2
LCALL L?0044
JC ?C0027
; sector-=MBR.sectors_per_fat;
; SOURCE LINE # 272
LCALL L?0046
MOV A,R6
PUSH ACC
MOV A,R7
PUSH ACC
MOV DPTR,#MBR+06H
MOVX A,@DPTR
MOV R6,A
INC DPTR
MOVX A,@DPTR
MOV R3,A
XCH A,R2
MOV A,R6
XCH A,R2
POP ACC
MOV R7,A
POP ACC
MOV R6,A
MOV A,R7
SUBB A,R3
MOV R7,A
MOV A,R6
SUBB A,R2
MOV R6,A
MOV A,R5
SUBB A,#00H
MOV R5,A
MOV A,R4
SUBB A,#00H
LCALL L?0055
SJMP ?C0025
?C0027:
; while(sector<Sect_Root_Dir()){ // Write same data to each FAT copy.
; SOURCE LINE # 273
LCALL Sect_Root_Dir
LCALL L?0044
JNC ?C0029
; Sect_Write(sector);
; SOURCE LINE # 274
LCALL L?0047
LCALL _Sect_Write
; sector+=MBR.sectors_per_fat;
; SOURCE LINE # 275
MOV DPTR,#sector?647
MOVX A,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
MOV R1,A
INC DPTR
MOVX A,@DPTR
MOV R2,A
INC DPTR
MOVX A,@DPTR
MOV R3,A
MOV DPTR,#MBR+06H
MOVX A,@DPTR
MOV R6,A
INC DPTR
MOVX A,@DPTR
MOV R7,A
CLR A
MOV R4,A
MOV R5,A
MOV A,R3
ADD A,R7
MOV R7,A
MOV A,R2
ADDC A,R6
MOV R6,A
MOV A,R5
ADDC A,R1
MOV R5,A
MOV A,R4
ADDC A,R0
LCALL L?0055
; }
; SOURCE LINE # 276
SJMP ?C0027
; }
; SOURCE LINE # 277
; }
; SOURCE LINE # 278
?C0029:
RET
; END OF _Sect_Write_Multi_Fat
;
; //----------------------------------------------------------------------------
; // Sect_Root_Dir
; //----------------------------------------------------------------------------
; //
; // Returns number of sector for root directory
; //
; // Parameters :
; // Return Value : number of sectors
; //----------------------------------------------------------------------------
;
; unsigned Sect_Root_Dir(void)
RSEG ?PR?Sect_Root_Dir?F34X_MSD_SECT_SERV
Sect_Root_Dir:
USING 0
; SOURCE LINE # 290
; {
; SOURCE LINE # 291
; return MBR.hidden_sectors +
; SOURCE LINE # 292
MOV DPTR,#MBR+01H
MOVX A,@DPTR
MOV R7,A
MOV R6,#00H
MOV DPTR,#MBR+06H
MOVX A,@DPTR
MOV R4,A
INC DPTR
MOVX A,@DPTR
MOV R5,A
LCALL ?C?IMUL
MOV DPTR,#MBR+0CH
MOVX A,@DPTR
MOV R4,A
INC DPTR
MOVX A,@DPTR
MOV R5,A
MOV DPTR,#MBR+0FH
MOVX A,@DPTR
ADD A,R5
MOV R5,A
MOV DPTR,#MBR+0EH
MOVX A,@DPTR
ADDC A,R4
XCH A,R5
ADD A,R7
MOV R7,A
MOV A,R5
ADDC A,R6
MOV R6,A
; MBR.reserved_sectors + /* Boot record followed by FATs */
; MBR.fat_copies*MBR.sectors_per_fat;
; }
; SOURCE LINE # 295
?C0030:
RET
; END OF Sect_Root_Dir
;
; //----------------------------------------------------------------------------
; // Sect_Root_Dir_Last
; //----------------------------------------------------------------------------
; //
; // Returns number of last sector for root directory
; //
; // Parameters :
; // Return Value : number of last sector
; //----------------------------------------------------------------------------
;
; unsigned Sect_Root_Dir_Last(void)
RSEG ?PR?Sect_Root_Dir_Last?F34X_MSD_SECT_SERV
Sect_Root_Dir_Last:
USING 0
; SOURCE LINE # 307
; {
; SOURCE LINE # 308
; return Sect_Root_Dir() - 1
; SOURCE LINE # 309
LCALL Sect_Root_Dir
MOV A,R7
ADD A,#0FFH
MOV R5,A
MOV A,R6
ADDC A,#0FFH
MOV R4,A
MOV DPTR,#MBR+02H
MOVX A,@DPTR
MOV R6,A
INC DPTR
MOVX A,@DPTR
MOV R0,#05H
?C0036:
CLR C
RLC A
XCH A,R6
RLC A
XCH A,R6
DJNZ R0,?C0036
MOV A,R6
CLR C
RRC A
MOV R6,#00H
ADD A,R5
MOV R7,A
MOV A,R6
ADDC A,R4
MOV R6,A
; + (MBR.root_directory_entries*DIRENTRY_SIZE)/PHYSICAL_BLOCK_SIZE;
; }
; SOURCE LINE # 311
?C0031:
RET
; END OF Sect_Root_Dir_Last
;
; //----------------------------------------------------------------------------
; // Sect_File_Data
; //----------------------------------------------------------------------------
; //
; // Returns first sector of file data
; //
; // Parameters :
; // Return Value : number of sector
; //----------------------------------------------------------------------------
;
; unsigned Sect_File_Data(void)
RSEG ?PR?Sect_File_Data?F34X_MSD_SECT_SERV
Sect_File_Data:
USING 0
; SOURCE LINE # 323
; {
; SOURCE LINE # 324
; return Sect_Root_Dir_Last() + 1 - (MBR.sectors_per_cluster*2); // First file data block is called "number 2".
; SOURCE LINE # 325
LCALL Sect_Root_Dir_Last
MOV A,R7
ADD A,#01H
MOV R5,A
CLR A
ADDC A,R6
MOV R4,A
MOV DPTR,#MBR+010H
MOVX A,@DPTR
MOV B,#02H
MUL AB
MOV R7,A
CLR C
MOV A,R5
SUBB A,R7
MOV R7,A
MOV A,R4
SUBB A,B
MOV R6,A
; }
; SOURCE LINE # 326
?C0032:
RET
; END OF Sect_File_Data
;
;
; //----------------------------------------------------------------------------
; // Sect_Fat1
; //----------------------------------------------------------------------------
; //
; // Returns first sector of 1-st FAT
; //
; // Parameters :
; // Return Value : number of sector
; //
; // NOTE: Changed this function in a #define, to safe code memory
; //----------------------------------------------------------------------------
;
; unsigned Sect_Fat1(void)
RSEG ?PR?Sect_Fat1?F34X_MSD_SECT_SERV
Sect_Fat1:
USING 0
; SOURCE LINE # 341
; {
; SOURCE LINE # 342
; return MBR.hidden_sectors + MBR.reserved_sectors;
; SOURCE LINE # 343
LCALL L?0053
; }
; SOURCE LINE # 344
?C0033:
RET
; END OF Sect_Fat1
;
; //----------------------------------------------------------------------------
; // Sect_Fat2
; //----------------------------------------------------------------------------
; //
; // Returns first sector of 2-st FAT
; //
; // Parameters :
; // Return Value : number of sector
; //
; // NOTE: Changed this function in a #define, to safe code memory
; //----------------------------------------------------------------------------
;
; unsigned Sect_Fat2(void)
RSEG ?PR?Sect_Fat2?F34X_MSD_SECT_SERV
Sect_Fat2:
USING 0
; SOURCE LINE # 358
; {
; SOURCE LINE # 359
; return MBR.hidden_sectors + MBR.reserved_sectors+MBR.sectors_per_fat;
; SOURCE LINE # 360
LCALL L?0053
MOV DPTR,#MBR+07H
MOVX A,@DPTR
ADD A,R7
MOV R7,A
MOV DPTR,#MBR+06H
MOVX A,@DPTR
ADDC A,R6
MOV R6,A
; }
; SOURCE LINE # 361
?C0034:
RET
; END OF Sect_Fat2
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -