mailto: blog -at- heyrick -dot- eu

Navi: Previous entry Display calendar Next entry
Switch to desktop version

FYI! Last read at 19:04 on 2024/11/21.

RISC OS source mods

This is mostly for me, to remind me how to tweak the RISC OS code when I update the source files to the current version (I do this every few months so I'm not too out of step). However, the modifications may be useful to you too, if you build your own version of RISC OS.

#1 Support CET/CEST timezone in UK territory.

As previously described, provides direct support for Western European time in the standard UK territory. Because creating a new territory and linking it into the system is a huge pain in the ass when you only want to tweak something that Territory should have kept its nose out of in the first place.

In the file ...castle.RiscOS.Sources.Internat.Territory.Module.s.UK, change line 55 from:

MaxTZLength     *       3       ; "GMT"
to:
MaxTZLength     *       4       ; "CEST"

Then change from line 61 from:

NumberOfTZ      *       1

        GBLS    NODST0
NODST0  SETS    "GMT"

        GBLS    DST0
DST0    SETS    "BST"

NODSTOffset0    *       100*60*60*0     ; Zero hours
DSTOffset0      *       100*60*60*1
to:
NumberOfTZ      *       2

        GBLS    NODST0
NODST0  SETS    "GMT"

        GBLS    DST0
DST0    SETS    "BST"

NODSTOffset0    *       100*60*60*0     ; Zero hours
DSTOffset0      *       100*60*60*1

        GBLS    NODST1
NODST1  SETS    "CET"

        GBLS    DST1
DST1    SETS    "CEST"

NODSTOffset1    *       100*60*60*1
DSTOffset1      *       100*60*60*2

 

#2 Fix SharedCLibrary localtime()

As previously described, the localtime() function uses the SWI Territory_ReadTimeZones to determine the current timezone offset from GMT. This was, unfortunately, the wrong call to make so will only ever return the offset of the first timezone in a multi-timezone setting. In other words, if you apply the above patch and select CET/CEST as your timezone, localtime() will just blindly go ahead and return values for GMT/BST.

Starting from line 257 of ...castle.RiscOS.Sources.Lib.RISC_OSLib.c.time, change:

    territory = __locales[N_LC_TIME];
    if (!territory) {
        r.r[0] = -1; /* If C locale use current configured territory */
    } else {
        r.r[0] = TERRITORY_EXTRACT(territory);
        r.r[1] = TERRITORY_TZ_EXTRACT(territory);
        r.r[4] = TERRITORY_TZ_API_EXT; /* If not supported, never mind */
    }
    if (_kernel_swi(Territory_ReadTimeZones, &r, &r) == NULL) {
        v = (dst == 0x8000) ? r.r[3] : r.r[2];
        t += v / 100; /* centiseconds -> seconds */
    }
to be:
    territory = __locales[N_LC_TIME];

    if ( !territory )
    {
        // If C locale, use the currently configured timezone
        // of the currently configured territory
        r.r[2] = 0; // make sure it does not say "ZONE"
        _kernel_swi(Territory_ReadCurrentTimeZone, &r, &r);
        t += (r.r[1] / 100); // centiseconds -> seconds
    }
    else
    {
        // Custom locale - work it out from the specified
        // timezone and DST setting
        r.r[0] = TERRITORY_EXTRACT(territory);
        r.r[1] = TERRITORY_TZ_EXTRACT(territory);
        r.r[4] = TERRITORY_TZ_API_EXT; /* If not supported, never mind */
        if (_kernel_swi(Territory_ReadTimeZones, &r, &r) == NULL)
        {
            v = (dst == 0x8000) ? r.r[3] : r.r[2];
            t += v / 100; /* centiseconds -> seconds */
        }
    }

 

#3 Adjust-click on Switcher icon opens system configuration

In ...castle.RiscOS.Sources.Desktop.Switcher.s.Switcher, from line 4332, delete the code between click_select and power_click (checking for h_powerdown, h_shutdown, h_savedbox, h_switcher and iconbar_handle) and place the following code there instead:
click_select
        LDR     R0,[R1,#b_window]
        CMP     R0,#iconbar_whandle
        BEQ     openswitcher
        BNE     click_common

click_adjust
        LDR     R0,[R1,#b_window]
        CMP     R0,#iconbar_whandle
        BEQ     goconfig

; it's not a click on the iconbar icon so try our windows
; for this we treat select and adjust click the same

click_common
        LDR     R14,h_powerdown         ; was it the power down dialogue
        TEQ     R0,R14
        BEQ     power_click

        LDR     R14,h_shutdown          ; click in restart dialogue?
        TEQ     R0,R14
        BEQ     restart

        LDR     R14,h_savedbox
        TEQ     R0,R14
        BEQ     dbox_click

        LDR     R14,h_switcher          ; click in task window?
        TEQ     R0,R14                  ; no => assume iconbar icon
        BEQ     switcher_click

        Pull    "PC"                    ; ignore it if none of these
Original hack by Rick Murray, optimised by Fred Graute.

 

#4 Double the size of the RAMdisc

Older source:
In ...castle.RiscOS.Sources.Kernel.s.NewReset, around line 1304, you should see:
        MOV     r5, #128*1024*1024      ; A trade off between [...etc...]
Change the "128" to a larger value, such as 256. Note that it must be a value that can be represented by a MOV instruction.

Newer source:
In ...castle.RiscOS.Sources.Kernel.hdr.Options, around line 317, you should see:

MaxRAMFS_Size   SETA    128            ; Max size available for RAM Disc
Change the "128" to a larger value, such as "256". As above, it is multiplied by 1024*1024, so it must eventually be a value that can be represented by a MOV instruction.

Please be aware that the ARM has only 4GiB of logical address space, and the RAMdisc "claims" the amount requested permanently. If the RAMdisc remains unused, then no memory is claimed or mapped in, but that much space is always allocated in the logical memory map. For this reason, the largest sensible RAMdisc size is possibly 256MiB or 320MiB, depending on how much physical memory you have on-board. RAMdisc would be a candidate for being implemented differently, some day...

 

#5 Run IIC at a decent speed

By default, RISC OS runs its IIC bus at 100kHz. This means approximately 12.5KiB/sec. This is '80s tech. This is sloooow.
Given that the IIC bus runs at 3.3V, if you are using 3.3V hardware, then that hardware is probably new enough to run at the faster 400kHz speed (~50KiB/sec). Compatibility problems ought to be minimal, the Fast Mode was introduced in 1992 - that's twenty two years ago.

To do this on a RaspberryPi, go to ...mixed.RiscOS.Sources.HAL.BCM2836.s.IIC and change lines 54 and 55 from:

; IIC divider to give 100 kHz
IICDivider             * 2496
to:
; IIC divider to give ~400 kHz
IICDivider             * 624

For the OMAP3 hardware (Beagle boards), you will want to look at the relevant HAL code. OMAP3 sets the speed around line 127, though I've not looked to see what values are required.
You don't need to modify OMAP4 (Panda) hardware, it already runs at 400kHz.
You should leave Iyonix and IOMD hardware running at 100kHz. If any machine is likely to interface with old (slow) hardware, it's the RiscPC... moreso given that there is no hardware IIC controller on either device, it's all done by directly bashing two lines on the IOMD (RiscPC) and whatever the I/O chip in the Iyonix is - about as technically advanced as the original Archimedes!

 

 

Your comments:

No comments yet...

Add a comment (v0.11) [help?]
Your name:

 
Your email (optional):

 
Validation:
Please type 95619 backwards.

 
Your comment:

 

Navi: Previous entry Display calendar Next entry
Switch to desktop version

Search:

See the rest of HeyRick :-)