mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
sfp.c takes handle_sfp, sfp_module_read, sfp_apply_quirks, sfp_get_info, sfp_read_field, sfp_print_info, setup_sfp_gpio, the quirk table and the module state that goes with them. Everything exported is __banked: handle_sfp() and sfp_print_info() are reached from cmd_parser.c in BANK2, the rest from the common area, and both are bank boundaries. The quirk table needed checking rather than assuming. Its entries are __code pointers, and a __code pointer carries no bank, so passing one to a function in a different bank hands it an offset read through the wrong window. That is safe here because strcmp() sits in the common segment at 0x51f and is reached with a plain lcall, so the bank register still says 3 while it runs. Verified in the built image: the table at 0x35580 holds 0x563c and 0x5644, which resolve to "QSFPTEK" and "QT-SFP+-T" inside BANK3. Common segment 13393 -> 8432 bytes, leaving 7492 free rather than 2531. BANK3 holds 5710, BANK1 is unchanged and BANK2 grows by 31 for the trampolines. All 34 machines in machine.h build and link, and the same walk over the generated assembly finds no plain lcall crossing a bank boundary.
20 lines
641 B
C
20 lines
641 B
C
#ifndef SFP_H
|
|
#define SFP_H
|
|
|
|
extern __xdata uint8_t sfp_pins_last;
|
|
extern __xdata char sfp_module_vendor[2][17];
|
|
extern __xdata char sfp_module_model[2][17];
|
|
extern __xdata char sfp_module_serial[2][17];
|
|
extern __xdata uint8_t sfp_options[2];
|
|
extern __xdata uint8_t sfp_speed[2];
|
|
extern __xdata uint8_t sfp_quirks[2];
|
|
|
|
bool sfp_print_info(uint8_t sfp) __banked;
|
|
bool sfp_read_field(__xdata char *dst, uint8_t sfp, uint8_t start, uint8_t length) __banked __reentrant;
|
|
bool sfp_get_info(uint8_t sfp) __banked;
|
|
void sfp_apply_quirks(uint8_t sfp) __banked __reentrant;
|
|
void setup_sfp_gpio(void) __banked;
|
|
void handle_sfp(void) __banked;
|
|
|
|
#endif
|