Commit 73eefecf authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Migrate 2012 RTC fix to Cortex branch of kernel

Detail:
  s/PMF/osword - Migrate the 2012 RTC fix from the HAL branch to the Cortex branch, plus apply similar fix to the code that handles HAL RTC devices (via new YearLOIsGood flag)
  s/PMF/i2cutils - Update HAL RTC year handling to correctly treat YearLO as either 2-bit int or 2-digit BCD
  hdr/RTCDevice - Add YearLOIsGood flag, revise NeedsYearHelp description
Admin:
  Tested on rev C2 beagleboard. Code seems to behave as intended.


Version 5.35, 4.79.2.98.2.21. Tagged as 'Kernel-5_35-4_79_2_98_2_21'
parent 6dfb2430
......@@ -13,11 +13,11 @@
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.35"
Module_Version SETA 535
Module_MinorVersion SETS "4.79.2.98.2.20"
Module_Date SETS "19 Jan 2010"
Module_ApplicationDate SETS "19-Jan-10"
Module_MinorVersion SETS "4.79.2.98.2.21"
Module_Date SETS "24 Jan 2010"
Module_ApplicationDate SETS "24-Jan-10"
Module_ComponentName SETS "Kernel"
Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel"
Module_FullVersion SETS "5.35 (4.79.2.98.2.20)"
Module_HelpVersion SETS "5.35 (19 Jan 2010) 4.79.2.98.2.20"
Module_FullVersion SETS "5.35 (4.79.2.98.2.21)"
Module_HelpVersion SETS "5.35 (24 Jan 2010) 4.79.2.98.2.21"
END
......@@ -5,19 +5,19 @@
*
*/
#define Module_MajorVersion_CMHG 5.35
#define Module_MinorVersion_CMHG 4.79.2.98.2.20
#define Module_Date_CMHG 19 Jan 2010
#define Module_MinorVersion_CMHG 4.79.2.98.2.21
#define Module_Date_CMHG 24 Jan 2010
#define Module_MajorVersion "5.35"
#define Module_Version 535
#define Module_MinorVersion "4.79.2.98.2.20"
#define Module_Date "19 Jan 2010"
#define Module_MinorVersion "4.79.2.98.2.21"
#define Module_Date "24 Jan 2010"
#define Module_ApplicationDate "19-Jan-10"
#define Module_ApplicationDate "24-Jan-10"
#define Module_ComponentName "Kernel"
#define Module_ComponentPath "castle/RiscOS/Sources/Kernel"
#define Module_FullVersion "5.35 (4.79.2.98.2.20)"
#define Module_HelpVersion "5.35 (19 Jan 2010) 4.79.2.98.2.20"
#define Module_FullVersion "5.35 (4.79.2.98.2.21)"
#define Module_HelpVersion "5.35 (24 Jan 2010) 4.79.2.98.2.21"
#define Module_LibraryVersionInfo "5:35"
......@@ -41,7 +41,8 @@ RTCTimeFormat_BCD * 0
; BCD format details
RTCFormatFlags_BCD_1BasedDay * 1 :SHL: 0 ; is DayOfMonth 0-based or 1-based?
RTCFormatFlags_BCD_1BasedMonth * 1 :SHL: 1 ; is Month 0-based or 1-based?
RTCFormatFlags_BCD_NeedsYearHelp * 1 :SHL: 2 ; If this is set, RISC OS assumes only the RTC is only able to store the two lowest bits of YearLO. If this is unset, the RTC must be able to store the full two-byte year.
RTCFormatFlags_BCD_NeedsYearHelp * 1 :SHL: 2 ; If this is set, RISC OS assumes only the RTC is unable to store the full two-byte year.
RTCFormatFlags_BCD_YearLOIsGood * 1 :SHL: 3 ; If this bit is not set, RISC OS treats YearLO as a 2-bit uint. Else it is treated as a 2-digit BCD value. If YearLOIsGood is not set, NeedsYearHelp must be set.
; Struct for storing BCD time
^ 0
......@@ -51,7 +52,7 @@ RTCTimeStruct_BCD_Minutes # 1
RTCTimeStruct_BCD_Hours # 1
RTCTimeStruct_BCD_DayOfMonth # 1
RTCTimeStruct_BCD_Month # 1
RTCTimeStruct_BCD_YearLO # 1
RTCTimeStruct_BCD_YearLO # 1 ; Note: Will be sent and received as a 2-bit int if YearLOIsGood is not set
RTCTimeStruct_BCD_YearHI # 1
RTCTimeStruct_BCD_Size * :INDEX: @
......
......@@ -1252,8 +1252,11 @@ SetTime ROUT
MOV R0, R3
SUBEQ R0, R0, #1
BL HTBS9
MOV R0, R5
BL HTBS9
TST R1, #RTCFormatFlags_BCD_YearLOIsGood
ANDEQ R0, R5, #3 ; 2 bit YearLO
STREQB R0, [R9], #1
MOVNE R0, R5 ; BCD YearLO
BLNE HTBS9
MOV R0, R6
BL HTBS9
12
......
......@@ -731,77 +731,85 @@ CheckYear ROUT
MOV R0, #0
LDR R0, [R0, #RTCFitted]
[ HAL
CMP R0, #2048
CMP R0, #2048
[ RTCSupport
BLO %FT8
BLO %FT8
|
BLO %FT15
BLO %FT15
]
; Ask the RTC what it thinks the year is
Push "R3,R10,R12"
MOV R10, R0
SUB R13, R13, #RTCTimeStruct_BCD_Size
MOV R1, R13
ADRL R2, HALRTC_IICOp
MOV LR, PC
LDR PC, [R0, #HALDevice_RTCReadTime]
; Did we succeed?
CMP R0, #RTCRetCode_OK
LDRB R0, [R13, #RTCTimeStruct_BCD_YearLO]
LDRB R1, [R13, #RTCTimeStruct_BCD_YearHI]
ADD R13, R13, #RTCTimeStruct_BCD_Size
LDRB R2, [R10, #HALDevice_RTCFormatFlags]
Pull "R3,R10,R12"
BNE %FT15
TST R2, #RTCFormatFlags_BCD_NeedsYearHelp
BNE %FT9
; Year is reliable; convert R0 & R1 to ints and update CMOS if necessary.
BL BCDToHex
MOV R2, R1
MOV R1, R0 ; YearLO
MOV R0, #YearCMOS
BL Read
CMP R0, R1
MOVNE R0, #YearCMOS
BLNE Write
MOV R0, R2
BL BCDToHex
MOV R1, R0 ; YearHI
MOV R0, #YearCMOS+1
BL Read
CMP R0, R1
MOVNE R0, #YearCMOS+1
BLNE Write
B %FT15
; Ask the RTC what it thinks the year is
Push "R3,R10,R12"
MOV R10, R0
SUB R13, R13, #RTCTimeStruct_BCD_Size
MOV R1, R13
ADRL R2, HALRTC_IICOp
MOV LR, PC
LDR PC, [R0, #HALDevice_RTCReadTime]
; Did we succeed?
CMP R0, #RTCRetCode_OK
LDRB R0, [R13, #RTCTimeStruct_BCD_YearLO]
LDRB R1, [R13, #RTCTimeStruct_BCD_YearHI]
ADD R13, R13, #RTCTimeStruct_BCD_Size
LDRB R2, [R10, #HALDevice_RTCFormatFlags]
Pull "R3,R10,R12"
BNE %FT15
ASSERT RTCFormatFlags_BCD_NeedsYearHelp = 1 :SHL: 2
ASSERT RTCFormatFlags_BCD_YearLOIsGood = 1 :SHL: 3
AND LR, R2, #RTCFormatFlags_BCD_NeedsYearHelp + RTCFormatFlags_BCD_YearLOIsGood
MOVS LR, LR, ROR #3 ; CC = good, CS+EQ = 2 bit, CS+NE = BCD
ADDCS R1, LR, #RTCAddressPHI+1 ; 2 bit=RTCAddressPHI+1, BCD!=RTCAddressPHI+1
BCS %FT9
; Year is reliable; convert R0 & R1 to ints and update CMOS if necessary.
BL BCDToHex
MOV R2, R1
MOV R1, R0 ; YearLO
MOV R0, #YearCMOS
BL Read
CMP R0, R1
MOVNE R0, #YearCMOS
BLNE Write
MOV R0, R2
BL BCDToHex
MOV R1, R0 ; YearHI
MOV R0, #YearCMOS+1
BL Read
CMP R0, R1
MOVNE R0, #YearCMOS+1
BLNE Write
B %FT15
8
] ; HAL
[ RTCSupport :LOR: :LNOT: HAL
TEQ R0, #RTCAddressPHI
MOVEQ R1, #5
MOVNE R1, #6 ; year address (dependant on RTC)
SUB R13, R13, #4
STRB R1, [R13]
MOV R1, R13
ORR R0, R0, #1:SHL:29
MOV R2, #1
STRB R1, [R13, #-4]!
MOV R1, R13
ORR R0, R0, #1:SHL:29
MOV R2, #1
BL IIC_Op
ORR R0, R0, #1
BL IIC_Op
ORR R0, R0, #1
BL IIC_Op
AND R1, R0, #&FF
LDRB R0, [R13]
ADD R13, R13, #4
AND R1, R0, #&FF
LDRB R0, [R13], #4
TEQ R1, #RTCAddressPHI+1
MOVEQ R1, R0, LSR #6
] ; RTCSupport :LOR: :LNOT: HAL
9
ANDNE R1, R0, #3 ; R1= year MOD 4. Note sharing of NE condition with HAL code.
MOVEQ R0, R0, LSR #6 ; R0= year MOD 4.
BLNE BCDToHex
MOV R2, R0 ; remember RTC value
MOV R0, #YearCMOS
BL Read
AND R2, R0, #3
SUBS R2, R1, R2 ; same year ?
TEQ R1, #RTCAddressPHI+1
ANDEQ R1, R0, #3
MOVNE R1, R0
MOVEQ R14,#4
MOVNE R14,#100
SUBS R2, R2, R1 ; same year ?
Pull "R0,R1,R2,PC", EQ ; [yes, so no bother]
ADDCC R2, R2, #4 ; if lower, then must be carry
ADDCC R2, R2, R14 ; if lower, then must be carry
ADD R2, R0, R2 ; new year value
CMP R2, #100
BCC %FT10 ; no carry thru to next century
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment