Progress
It took me a little while to figure out why my bank wasn’t running. asm(“call 4030”) does not output machine code that jumps to 0x4030–it jumps to 4030 or 0x0fbe. That’s wrong. So I added in the “0x” and all was well.
So now I am starting to wrap up a refactoring exercise.
I added a block that will go in all 16 sections. Each will have a pointer at 0x0026 that will point to this block.
1 #define BANKINFO_TYPE_UNKNOWN ((uint8_t)0x00)
2 #define BANKINFO_TYPE_CVECTOR ((uint8_t)0x01)
3 #define BANKINFO_TYPE_APPLET ((uint8_t)0x02)
4 #define BANKINFO_TYPE_EXECUTABLE ((uint8_t)0x03)
5
6 // Every bank has a pointer at 0026 that points to a const BankInfo* _BANK_INFO; both crt0.s and crt1.s
7 // expect a _BANK_INFO to be defined. This will typically be where main is defined.
8
9 typedef struct BankInfo {
10 uint16_t CVersion; // 0{ix} 1(ix)
11 const char* Name; // 2{ix} 3(ix)
12 const char* TimeStamp; // 4{ix} 5(ix)
13 uint8_t Flags; // 6{ix}
14 uint8_t Type; // 7(ix) 1=c vector, 2=applet, 3=bank
15 uint16_t W0102; // 8{ix} 9(ix) // valid only is this is 0102
16 uint16_t W0304; // 10{ix} 11(ix)
17 } BankInfo;
This will be used for listing the contents of the flash. There will be 3 types of flash banks:
- C Vector: These have the C library and drivers that the applets can use. But they don't really need anything else.
- Applet: These will run the programs that I want to run
- Executable: These will run standalone programs or menu items.
The applets require that they are linked with crt1.rel. The others with crt0.s. The C vectors need to link in c_vector.c.
At this point, I have to start reserving certain banks: 00: flash bank 0 is always run from reset. It will have a standalone executable with complex menu, but no c vector 01: flash bank 1 is always in bank 1 from reset. It will always be available for bank 00 to be able to hold programs larger than 16K. 10: RAM bank 10: This will be placed in bank 2 (i.e. 0x8000-0xbfff). It is there by default 11: RAM bank 11: This will be placed in bank 2 (i.e. 0xc000-0xffff). It is there by default