Still simpler to just write my own than to try to get the compiler to let me include its version (and deal with any incompatibilities that come up).Korona wrote:stdint.h is provided by the compiler, its part of C's freestanding subset.
I can't really remember everything that went on in there. I wasn't doing this patching thing originally, but I was having difficulty getting it to compile after I changed something else (I can't remember what or why it made it refuse to compile) so I just hacked this together because my main priority at the time was to get the interrupts to my interrupt dispatcher function and implement my kernel's interrupt API and get that working, without worrying too much about exactly how the interrupts get to the interrupt dispatcher. I can always change this later, it's about three or four lines of assembler to get the interrupts to the interrupt dispatcher and the rest is just plain C code.Korona wrote:EDIT: Oh, I see, it's patching the assembly at runtime because you didn't use the correct constraint for it to accept static function pointers (IIRC it's p with a c modifier). Oh dog. Not only will this fail if your code segment is write-protected (which it really should be), it is also daily WTF worthy.Code: Select all
current_offset = 0;\ while (*((uint32_t*) (&&isr_start + current_offset)) != 0x01234567)\ {\ current_offset++;\ }\ *((uint32_t*) (&&isr_start + current_offset)) = irq_handler;
Write your stubs in a real assembler file, not in some kind of hacky and unreadable inline assembler. If you really want to write it in inline assembler, use GCC's unit-level assembly extension.