Add wormhole.[ch]
This commit is contained in:
@@ -112,7 +112,7 @@
|
|||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.cref.742351963" name="Cross reference (-Xlinker --cref)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.cref" value="false" valueType="boolean"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.cref.742351963" name="Cross reference (-Xlinker --cref)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.cref" value="false" valueType="boolean"/>
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.printgcsections.192927503" name="Print removed sections (-Xlinker --print-gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.printgcsections" value="false" valueType="boolean"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.printgcsections.192927503" name="Print removed sections (-Xlinker --print-gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.printgcsections" value="false" valueType="boolean"/>
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.strip.1437487702" name="Omit all symbol information (-s)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.strip" value="false" valueType="boolean"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.strip.1437487702" name="Omit all symbol information (-s)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.strip" value="false" valueType="boolean"/>
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other.237939626" name="Other linker flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other" value=" -Wall --specs=nano.specs -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -Xlinker -static -Xlinker -z -Xlinker muldefs " valueType="string"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other.237939626" name="Other linker flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other" value=" -Wall --specs=nano.specs -fno-common -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -mapcs -Xlinker -static -Xlinker -z -Xlinker muldefs" valueType="string"/>
|
||||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input.1959593877" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input">
|
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input.1959593877" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input">
|
||||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "bootloader_config.h"
|
#include "bootloader_config.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "test_states.h"
|
#include "test_states.h"
|
||||||
|
#include "wormhole.h"
|
||||||
|
|
||||||
key_matrix_t KeyMatrix = {
|
key_matrix_t KeyMatrix = {
|
||||||
.colNum = KEYBOARD_MATRIX_COLS_NUM,
|
.colNum = KEYBOARD_MATRIX_COLS_NUM,
|
||||||
@@ -90,33 +91,14 @@ void UpdateUsbReports()
|
|||||||
IsUsbBasicKeyboardReportSent = false;
|
IsUsbBasicKeyboardReportSent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t magicNumber;
|
|
||||||
uint8_t enumerationMode;
|
|
||||||
} wormhole_t;
|
|
||||||
|
|
||||||
wormhole_t *message_ptr __attribute__ ((__section__ (".noinit")));
|
|
||||||
|
|
||||||
void* getSP(void)
|
|
||||||
{
|
|
||||||
void *sp;
|
|
||||||
__asm__ __volatile__ ("mov %0, sp" : "=r"(sp));
|
|
||||||
return sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __attribute__ ((__section__ (".init3"), __naked__)) move_sp(void) {
|
|
||||||
void* SP = getSP();
|
|
||||||
SP -= sizeof(wormhole_t);
|
|
||||||
message_ptr = (wormhole_t*)(SP + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
InitPeripherials();
|
InitPeripherials();
|
||||||
InitClock();
|
InitClock();
|
||||||
#ifdef ENABLE_BUSPAL
|
if (false/* || Wormhole->magicNumber == WORMHOLE_MAGIC_NUMBER*/) {
|
||||||
|
Wormhole->magicNumber = 0;
|
||||||
init_hardware();
|
init_hardware();
|
||||||
handleUsbBusPalCommand();
|
handleUsbBusPalCommand();
|
||||||
#else
|
} else {
|
||||||
LedDriver_InitAllLeds(1);
|
LedDriver_InitAllLeds(1);
|
||||||
InitBridgeProtocolScheduler();
|
InitBridgeProtocolScheduler();
|
||||||
KeyMatrix_Init(&KeyMatrix);
|
KeyMatrix_Init(&KeyMatrix);
|
||||||
@@ -129,5 +111,5 @@ void main() {
|
|||||||
UpdateUsbReports();
|
UpdateUsbReports();
|
||||||
asm("wfi");
|
asm("wfi");
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "led_pwm.h"
|
#include "led_pwm.h"
|
||||||
#include "bridge_protocol_scheduler.h"
|
#include "bridge_protocol_scheduler.h"
|
||||||
#include "bridge_slaves/bridge_slave_uhk_module.h"
|
#include "bridge_slaves/bridge_slave_uhk_module.h"
|
||||||
|
#include "wormhole.h"
|
||||||
|
|
||||||
void setError(uint8_t error);
|
void setError(uint8_t error);
|
||||||
void setGenericError();
|
void setGenericError();
|
||||||
@@ -109,6 +110,7 @@ void getSystemProperty() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void jumpToBootloader() {
|
void jumpToBootloader() {
|
||||||
|
// Wormhole->magicNumber = WORMHOLE_MAGIC_NUMBER;
|
||||||
SCB->AIRCR = 0x5FA<<SCB_AIRCR_VECTKEY_Pos | SCB_AIRCR_SYSRESETREQ_Msk; // Reset the MCU.
|
SCB->AIRCR = 0x5FA<<SCB_AIRCR_VECTKEY_Pos | SCB_AIRCR_SYSRESETREQ_Msk; // Reset the MCU.
|
||||||
for (;;);
|
for (;;);
|
||||||
}
|
}
|
||||||
|
|||||||
17
right/src/wormhole.c
Normal file
17
right/src/wormhole.c
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "wormhole.h"
|
||||||
|
|
||||||
|
wormhole_t *Wormhole NO_INIT_GCC;
|
||||||
|
|
||||||
|
void* getSP(void)
|
||||||
|
{
|
||||||
|
void *sp;
|
||||||
|
// __asm__ __volatile__ ("mov %0, sp" : "=r"(sp));
|
||||||
|
__asm__ __volatile__ ("mrs %0, msp" : "=r"(sp));
|
||||||
|
return sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __attribute__ ((__section__ (".init3"), __naked__)) move_sp(void) {
|
||||||
|
void* SP = getSP();
|
||||||
|
// SP -= sizeof(wormhole_t);
|
||||||
|
Wormhole = (wormhole_t*)(SP + 1);
|
||||||
|
}
|
||||||
24
right/src/wormhole.h
Normal file
24
right/src/wormhole.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef __WORMHOLE_H__
|
||||||
|
#define __WORMHOLE_H__
|
||||||
|
|
||||||
|
// Includes:
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// Macros:
|
||||||
|
|
||||||
|
#define WORMHOLE_MAGIC_NUMBER 0x3b04cd9e94521f9a
|
||||||
|
#define NO_INIT_GCC __attribute__ ((section (".noinit")))
|
||||||
|
|
||||||
|
// Typedefs:
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint64_t magicNumber;
|
||||||
|
uint8_t enumerationMode;
|
||||||
|
} wormhole_t;
|
||||||
|
|
||||||
|
// Variables:
|
||||||
|
|
||||||
|
extern wormhole_t *Wormhole NO_INIT_GCC;
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user