liemoth icon indicating copy to clipboard operation
liemoth copied to clipboard

Module System

Open petabyt opened this issue 4 years ago • 4 comments

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:

  • Implement module system
  • Revert build system
  • Finish ashp cli

petabyt avatar Sep 16 '21 18:09 petabyt

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);
}

petabyt avatar Sep 20 '21 18:09 petabyt

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.

coolkingcole avatar Sep 20 '21 18:09 coolkingcole

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 avatar Sep 20 '21 19:09 petabyt

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

petabyt avatar Mar 07 '22 15:03 petabyt