Commit 0595a541 authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL
Browse files

Fix OS_Byte 166 for high ZeroPage, make read-only

Despite never being properly documented in the RISC OS PRMs, there's
evidence that Acorn were recommending that third-parties used OS_Byte
166 for locating the OS_Byte variables well into the mid-1990's:

https://www.riscosopen.org/forum/forums/5/topics/14676#posts-94080

Currently OS builds which use zero page relocation will only return the
low 16 bits of the address from OS_Byte 166, most likely breaking any
third-party software which is trying to use it. Attempt to restore
compatibility by having OS_Byte 166 add the missing high address bits
into the "next location" value returned in R2, and fix OS_Byte 167 in a
similar manner (adding into R1).

Additionally, make the values read-only, because the kernel is littered
with code that uses hard-coded OsbyteVars addresses and so is unlikely
to do anything sensible if someone was to modify the OsbyteVars address
that's stored in workspace.

Version 6.39. Tagged as 'Kernel-6_39'
parent 2991e2df
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "6.38"
Module_Version SETA 638
Module_MajorVersion SETS "6.39"
Module_Version SETA 639
Module_MinorVersion SETS ""
Module_Date SETS "23 May 2020"
Module_ApplicationDate SETS "23-May-20"
Module_Date SETS "22 Jun 2020"
Module_ApplicationDate SETS "22-Jun-20"
Module_ComponentName SETS "Kernel"
Module_FullVersion SETS "6.38"
Module_HelpVersion SETS "6.38 (23 May 2020)"
Module_FullVersion SETS "6.39"
Module_HelpVersion SETS "6.39 (22 Jun 2020)"
END
/* (6.38)
/* (6.39)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 6.38
#define Module_MajorVersion_CMHG 6.39
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 23 May 2020
#define Module_Date_CMHG 22 Jun 2020
#define Module_MajorVersion "6.38"
#define Module_Version 638
#define Module_MajorVersion "6.39"
#define Module_Version 639
#define Module_MinorVersion ""
#define Module_Date "23 May 2020"
#define Module_Date "22 Jun 2020"
#define Module_ApplicationDate "23-May-20"
#define Module_ApplicationDate "22-Jun-20"
#define Module_ComponentName "Kernel"
#define Module_FullVersion "6.38"
#define Module_HelpVersion "6.38 (23 May 2020)"
#define Module_LibraryVersionInfo "6:38"
#define Module_FullVersion "6.39"
#define Module_HelpVersion "6.39 (22 Jun 2020)"
#define Module_LibraryVersionInfo "6:39"
......@@ -138,7 +138,7 @@ OsByteGo ROUT
BAL Osbyte19
HiOsbyte
CMP R0, #OsByte_BaseOfOSByteVarTable ; is it a variable ?
CMP R0, #OsByte_BaseOfROMVectorTable ; is it a variable ?
30
ADDCC PC, PC, R3, LSL #2
B DoOsbyteVar ; yes, then do variable mangling
......@@ -212,6 +212,8 @@ HiOsbyte
BAL OsbyteA3
BAL OsbyteA4
BAL OsbyteA5
BAL OsbyteA6
BAL OsbyteA7
TryInternational ; special ones in the middle
TEQ R0, #OsByte_Country
......@@ -1228,9 +1230,22 @@ OsbyteA5
ByteToNosbod DoReadPOSVPOSO ; Result in R1,R2 (Horiz,vert)
MyOsbyte
; Read OsbyteVars location. Legacy DoOsbyteVar API extended for 32bit high
; zero page address, and fixed to treat ByteVars as read-only (RISC OS has
; probably never supported modifying the value at runtime)
OsbyteA6
MOV R1,#(ZeroPage+OsbyteVars-&A6) :AND: 255
LDR R2,=(ZeroPage+OsbyteVars-&A6) :SHR: 8
MyOsbyte
OsbyteA7
LDR R1,=(ZeroPage+OsbyteVars-&A6) :SHR: 8
LDRB R2, [WsPtr, #2] ; "next location", OS_Byte &A8 R1 value
MyOsbyte
; *****************************************************************************
;
; All calls &A6 to &FF are implemented together.
; All calls &A8 to &FF are implemented together.
; <NEW VALUE> = (<OLD VALUE> AND R2 ) EOR R1
; The old value is returned in R1 and the next location is returned in R2
;
......
......@@ -376,7 +376,7 @@ ByteVarInitTable
; The main osbyte variables, accessed
; via calls &A6 to &FF
DCW OsbyteVars-&A6 ; VarStart # 2 ; &A6,&A7
DCW OsbyteVars-&A6 ; VarStart # 2 ; &A6,&A7. Note that OS_Byte &A6/&A7 now returns hardcoded values instead of referring to this value held in workspace; potentially we could remove/reuse this entire 10 byte block in the future.
= 0,0 ; ROMPtr # 2 ; &A8,&A9
= 0,0 ; ROMInfo # 2 ; &AA,&AB
= 0,0 ; KBTran # 2 ; &AC,&AD
......
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