Coder Social home page Coder Social logo

Comments (1)

TomKeddie avatar TomKeddie commented on August 20, 2024

@xobs moving conversation from #7 to this issue. Quoting the whole response here for continuity.

I was having a chat with @mithro, and the idea came up to use a thunked syscall interface.

The idea being that you'd have a function at a well-known address, or an address defined in a LiteX CSR, or an address defined in a RISC-V MSR, that has a function signature such as:

int syscall(uint32_t family, uint32_t syscall, uint32_t arg1, void *arg2);

...or similar. Maybe the params would be different. But we'd define family and syscall as enum pairs. For example, "reboot" might be in the "system" family. Using 32-bit IFF-style tags, such a call might be:

syscall('syst', 'boot', 0x20040000, NULL);

Because the boot ROM is currently always memory-mapped, we could fix it at address 0x100, so any machine-level program could cast that value to a function pointer and make syscalls.

Then, as part of the BIOS for various platforms, you'd implement syscall:

__attribute__((section(".text.syscall")))
int syscall(uint32_t family, uint32_t call, uint32_t arg1, void *arg2) {
    switch (family) {
        case 'syst':
            return do_syst(call, arg1, arg2);
        default:
            return -EIMPL;
    }
}

static int do_syst(uint32_t call, uint32_t arg1, void *arg2) {
    switch (family) {
        case 'boot':
            return do_reboot(arg1);
        default:
            return -EIMPL;
    }
}

Agreed, we could also define inlines/macros to make the code more readable.

syscall('syst', 'boot', 0x20040000, NULL);
could become
syscall_syst_boot(0x20040000);

Once we have the i/o for the bootloader defined in this manner we can take a look at defining some platform i/o for micropython. Stuff like rgb would be platform specific but we can define a very basic interface that exposes n buttons, n leds and a set of n io pins. On fomu the buttons could be touch under the hood. We'd also want to look ahead to circuitpython and make sure we can define an optional platform i2c in some manner too.

from foboot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.