petabyt / liemoth

Ambarella Action Camera Hacks
GNU General Public License v3.0
26 stars 2 forks source link

Module System #9

Open petabyt opened 2 years ago

petabyt commented 2 years ago

I've been taking a break from AHDK.

One of the things I've wanted to devise is some kind of
module system. I've already gotten a lot figured out already, such as stable platform independent
code, and jumping to allocated code. Now, I just have to figure out how to read an ELF file...

TODO:

petabyt commented 2 years ago

Some notes:
Elf format might not be a great idea. AHDK is sort of limited on memory.

#include <stdio.h>
#include <stdint.h>

// TODO: use uint8_t

typedef int _gpio(void);
_gpio* gpio = (_gpio*)0xdeadbeef;

struct AhdkModule {
    // This will never change
    unsigned int version;

    // Use {0, 0} as the function list
    // null-terminator
    struct Function {
        char *name;
        unsigned int addr;
    }funcs[];
};

struct AhdkModule asd = {
    1,
    {
        {"gpio", 0xa1e8},
        {0, 0}
    }
};

int main() {
    gpio = (_gpio*)((unsigned long)asd.funcs[0].addr);
}
coolkingcole commented 2 years ago

Could do a task system like in an rtos. Pie code that you could could inject and call like a task with ways to start/stop that particular code from running.

petabyt commented 2 years ago

Could do a task system like in an rtos. Pie code that you could could inject and call like a task with ways to start/stop that particular code from running.

As far as I know, that should be possible.

petabyt commented 2 years ago

Current spec: https://petabyt.dev/blog/tiny-embedded-module-system-spec

Project put on hold until I can fix my Ambarella camera, and when I'm not busy