📄 spl78k0_kx2.asm
字号:
; = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
;-----------------------------------------------------------------------------
SelfLib_SetInfo_SwapBootCluster: ;
PUSH BC ; push used register
MOV B,#MASK_SWAP_BOOTCLUSTER ; B <- security information
BR SelfLib_SetInfo_common ; goto common part of SetInfo
; -----------------------------------
#endif
#if (SI_CEP)
PUBLIC SelfLib_SetInfo_ChipEraseProtection
;-----------------------------------------------------------------------------
; Block type: selflib command function
; C prototype: u08 SelfLib_SetInfo_ChipEraseProtection(void);
; C example: my_status_u08 = SelfLib_SetInfo_ChipEraseProtection();
;-----------------------------------------------------------------------------
; Purpose: sets the chip-erase-protection flag in the extra area
; Input: -
; Output: -
; Returned: u08 - status code
; = 0x00(STS_NO_ERROR), normal
; = 0x05(STS_PARAMETER_ERROR), parameter error
; = 0x10(STS_PROTECTION_ERROR), protection error
; = 0x1A(STS_MRG10_ERROR), erase error
; = 0x1B(STS_MRG11_ERROR), internal verify error
; = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
;-----------------------------------------------------------------------------
SelfLib_SetInfo_ChipEraseProtection: ;
PUSH BC ; push used register
MOV B,#MASK_CHIP_ERASE_PROTECTION ; B <- security information
BR SelfLib_SetInfo_common ; goto common part of SetInfo
; -----------------------------------
#endif
#if (SI_BEP)
PUBLIC SelfLib_SetInfo_BlockEraseProtection
;-----------------------------------------------------------------------------
; Block type: selflib command function
; C prototype: u08 SelfLib_SetInfo_BlockEraseProtection(void);
; C example: my_status_u08 = SelfLib_SetInfo_BlockEraseProtection();
;-----------------------------------------------------------------------------
; Purpose: sets the block-erase-protection flag in the extra area
; Input: -
; Output: -
; Returned: u08 - status code
; = 0x00(STS_NO_ERROR), normal
; = 0x05(STS_PARAMETER_ERROR), parameter error
; = 0x10(STS_PROTECTION_ERROR), protection error
; = 0x1A(STS_MRG10_ERROR), erase error
; = 0x1B(STS_MRG11_ERROR), internal verify error
; = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
;-----------------------------------------------------------------------------
SelfLib_SetInfo_BlockEraseProtection: ;
PUSH BC ; push used register
MOV B,#MASK_BLOCK_ERASE_PROTECTION ; B <- security information
BR SelfLib_SetInfo_common ; goto common part of SetInfo
; -----------------------------------
#endif
#if (SI_WP)
PUBLIC SelfLib_SetInfo_WriteProtection
;-----------------------------------------------------------------------------
; Block type: selflib command function
; C prototype: u08 SelfLib_SetInfo_WriteProtection(void);
; C example: my_status_u08 = SelfLib_SetInfo_WriteProtection();
;-----------------------------------------------------------------------------
; Purpose: sets the write-protection flag in the extra area
; Input: -
; Output: -
; Returned: u08 - status code
; = 0x00(STS_NO_ERROR), normal
; = 0x05(STS_PARAMETER_ERROR), parameter error
; = 0x10(STS_PROTECTION_ERROR), protection error
; = 0x1A(STS_MRG10_ERROR), erase error
; = 0x1B(STS_MRG11_ERROR), internal verify error
; = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
;-----------------------------------------------------------------------------
SelfLib_SetInfo_WriteProtection: ;
PUSH BC ; push used register
MOV B,#MASK_WRITE_PROTECTION ; B <- security information
BR SelfLib_SetInfo_common ; goto common part of SetInfo
; -----------------------------------
#endif
#if (SI_BCP)
PUBLIC SelfLib_SetInfo_BootClusterProtection
;-----------------------------------------------------------------------------
; Block type: selflib command function
; C prototype: u08 SelfLib_SetInfo_BootClusterProtection(void);
; C example: my_status_u08 = SelfLib_SetInfo_BootClusterProtection();
;-----------------------------------------------------------------------------
; Purpose: sets the bootcluster-update-protection flag in the extra area
; Input: -
; Output: -
; Returned: u08 - status code
; = 0x00(STS_NO_ERROR), normal
; = 0x05(STS_PARAMETER_ERROR), parameter error
; = 0x10(STS_PROTECTION_ERROR), protection error
; = 0x1A(STS_MRG10_ERROR), erase error
; = 0x1B(STS_MRG11_ERROR), internal verify error
; = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
;-----------------------------------------------------------------------------
SelfLib_SetInfo_BootClusterProtection: ;
PUSH BC ; push used register
MOV B,#MASK_BOOTCLUSTER_PROTECTION ; B <- security information
BR SelfLib_SetInfo_common ; goto common part of SetInfo
; -----------------------------------
#endif
; if any SetInfo command included unwrap the common part
#if (SI_SBC OR SI_CEP OR SI_BEP OR SI_WP OR SI_BCP)
SelfLib_SetInfo_common: ; read actual security info
MOV A,#OPT_SECURITY_INFO ; {
MOV (entry_ram+IDX_OPTION_BYTE),A ; entry_ram[IDX_OPTION_BYTE] <- security
MOV A,#CMD_GET_INFO ; set command
CALL ASM_execute ; execute the "get info" command
CMP A,#STS_NO_ERROR ; }
BZ SelfLib_SetInfo_continue ; if (error) exit;
POP BC ; else
RET ; {
SelfLib_SetInfo_continue:
PUSH HL ; save used register
PUSH AX ; ---------------------------
MOVW AX,(entry_ram+IDX_DATA_BUF_H) ;
MOVW HL,AX ; HL <- address of data_buffer
MOV A,#0FFH ;
MOV1 CY,[HL].0 ;
MOV1 A.1,CY ;
MOV1 CY,[HL].1 ;
MOV1 A.2,CY ;
MOV1 CY,[HL].2 ;
MOV1 A.3,CY ;
MOV1 CY,[HL].4 ;
MOV1 A.5,CY ; A <- old security info
AND A,B ;
MOV [HL],A ; A <- new security info
; ------------------------------------
POP AX ; restore used register
MOV A,#CMD_SET_INFO ;
CALL ASM_execute ; execute the "set info" command
; -----------------------------
POP HL ; restore used register
POP BC ; restore used register
RET
#endif
;-----------------------------------------------------------------------------
; Block type: local assembler subroutine
; Purpose: execution of a specified command
; Input: A, selflib command code (defined in spl78k0_kx2_const.h)
; Output: -
; Returned: A, status_code (code defined in spl78k0_kx2_const.h)
;-----------------------------------------------------------------------------
ASM_execute:
PUSH PSW ; save user register bank context
MOV 0FEE2H,A ; RB3.C <- command code RB(user).A
SEL RB3 ; select RB3 for firmware operation
MOVW HL,#entry_ram ; RP3.HL <- &entry_ram
DI ;
MOV PFCMD,#0A5H ; ---------------------------
MOV FLPMC,#001H ;
MOV FLPMC,#0FEH ; set selfprogramming mode (A1)
MOV FLPMC,#001H ;
; ***************************
CALL 08100H ; >>>> call the firmware <<<<
; ***************************
MOV PFCMD,#0A5H ;
MOV FLPMC,#000H ; set "normal mode" (A0)
MOV FLPMC,#0FFH ;
MOV FLPMC,#000H ; ---------------------------
POP PSW ; restore user RB and EI context
MOV A,0FEE3H ; RB(user).A <- status code (RB3.B)
NOP ; eventually interrupt services
NOP ; eventually interrupt services
NOP ; eventually interrupt services
NOP ; eventually interrupt services
NOP ; eventually interrupt services
RET ;
; zero-terminated driver information string
SPL_INFO:
DB SPL_DEVICE,'/',SPL_VERSION,0x00
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -