8000 Remove overloaded meaning of __riscv__ symbol · Issue #18 · hoglet67/BBCSDL · GitHub
[go: up one dir, main page]

Skip to content

Remove overloaded meaning of __riscv__ symbol #18

Open

Description

@jgharston

In the update I've submitted I've used the riscv symbol to identify code for the RISC-V CoPro target, but riscv is doing two tasks that should be split up.

It is used to indicate code that needs to target a RISC-V CPU (eg register sizes, etc.), and also code that needs to target a RISC-V CPU that is using the Tube/BBC API. (eg COLOUR should do vdu(17),vdu(n), etc.). These are two different things.
For instance, there is nothing to stop there being a RISC-V build that runs on a RISC-V running Linux. So it needs to use Linux calls not Tube/BBC calls. Similarly, there is nothing stopping an ARM build to run on ARM RISC OS, so again would need to use RISC OS (ie, near enough Tube/BBC) calls.

On other code I've worked on I've used a cpu symbol to indicate the CPU targetted (eg arm 8086 riscv) and a osapi symbol to indicate the API being targetted (eg unix dos win). I suggest riscv be reduced to just indicating CPU-specific code, and introduce another symbol to indicate the API being used.

Activity

  1. jgharston commented on Jan 5, 2025

    @jgharston
    Author

    Some more thoughts.

    There's actually three categories of compilation symbols, not two.

    win unix etc indicates what sort of filing access to use
    arm riscv etc indicates the CPU being targetted, for register sizes and maths stuff, floor(), etc.

    And then there's the "console" I/O. By default the bbcmos.c module is included that directs everything to the SDL library. Including the riscv_wrapper.c instead directs I/O to the Tube/BBC I/O, but that is not riscv-specific, it is Tube/BBC I/O specific. The riscv_wrapper.c module would work perfectly fine for an ARM sending to OS_WRCH/OS_Byte/OS_File/etc, a PDP11 sending to OS_WRCH/OS_Byte/OS_File/etc, a 32000 sending to OS_WRCH/OS_Byte/OS_File/etc. The only thing RISC-V specific in riscv_wrapper.c is the wrappers around the ECALLs.

    So, I think there probably should be a MOS API Abstraction module which does things like getcsr() -> _osbyte(), which would be the same for PDP11/ARM/32000/Bambleweeny/whatever translates API calls to Tube/BBC API low level calls, and a RISC-V Low level MOS Interface and which does things like _osbyte() -> ECALL BYTE,a,x,y and os_quit() -> ECALL QUIT, etc. There could be a low-level MOS module for RISC OS that does SWI "OS_Byte", etc. for Pandora that does SVC OS_BYTE, for 32000 that does TRAP ACORN+BYTE, etc. etc. and still using the same API Abstration that does getcsr() -> _osbyte().

    Some more pondering forthcoming.

  2. hoglet67 commented on Jan 5, 2025

    @hoglet67
    Owner

    One thing to be aware of here... I'm not going to be accepting any changes that affect other builds of BBCSDL. And I have no plans to merge this work upstream back to Richard Russell (unless he specifically asks me to do this). Anything that pertains to more general restructuring should be taken up with Richard directly. I definitely don't want to act as an intermediary here!

    That said, anything that is local to the files that I have added is fine:

    • console/riscv/*
    • src/bbasmb_riscv.c
    • src/bbdata_riscv.s
    • src/riscv-wrapper.c

    I really want to minimise changes to any changes to files other than these, especially to those Richard considers "core"

    Dave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0