Move kboot related code to shared/kboot.[ch] because it'll be reused by the firmwares of the add-ons.
This commit is contained in:
@@ -1,14 +1,7 @@
|
|||||||
|
#include "kboot.h"
|
||||||
#include "i2c_addresses.h"
|
#include "i2c_addresses.h"
|
||||||
#include "bootloader.h"
|
#include "bootloader.h"
|
||||||
|
|
||||||
/* bits for enabledPeripherals */
|
|
||||||
#define ENABLE_PERIPHERAL_UART (1<<0)
|
|
||||||
#define ENABLE_PERIPHERAL_I2C (1<<1)
|
|
||||||
#define ENABLE_PERIPHERAL_SPI (1<<2)
|
|
||||||
#define ENABLE_PERIPHERAL_CAN (1<<3)
|
|
||||||
#define ENABLE_PERIPHERAL_USB_HID (1<<4)
|
|
||||||
#define ENABLE_PERIPHERAL_USB_MSC (1<<7)
|
|
||||||
|
|
||||||
__attribute__((used, section(".BootloaderConfig"))) const bootloader_config_t BootloaderConfig = {
|
__attribute__((used, section(".BootloaderConfig"))) const bootloader_config_t BootloaderConfig = {
|
||||||
.tag = 0x6766636B, // Magic Number
|
.tag = 0x6766636B, // Magic Number
|
||||||
.enabledPeripherals = ENABLE_PERIPHERAL_I2C,
|
.enabledPeripherals = ENABLE_PERIPHERAL_I2C,
|
||||||
@@ -17,15 +10,3 @@ __attribute__((used, section(".BootloaderConfig"))) const bootloader_config_t Bo
|
|||||||
.clockFlags = 0xFF, // Disable High speed mode
|
.clockFlags = 0xFF, // Disable High speed mode
|
||||||
.clockDivider = 0xFF, // Use clock divider (0)
|
.clockDivider = 0xFF, // Use clock divider (0)
|
||||||
};
|
};
|
||||||
|
|
||||||
void JumpToBootloader(void) {
|
|
||||||
uint32_t runBootloaderAddress;
|
|
||||||
void (*runBootloader)(void *arg);
|
|
||||||
|
|
||||||
/* Read the function address from the ROM API tree. */
|
|
||||||
runBootloaderAddress = **(uint32_t **)(0x1c00001c);
|
|
||||||
runBootloader = (void (*)(void * arg))runBootloaderAddress;
|
|
||||||
|
|
||||||
/* Start the bootloader. */
|
|
||||||
runBootloader(NULL);
|
|
||||||
}
|
|
||||||
|
|||||||
12
shared/kboot.c
Normal file
12
shared/kboot.c
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#include "kboot.h"
|
||||||
|
|
||||||
|
void JumpToKboot(void) {
|
||||||
|
uint32_t runBootloaderAddress;
|
||||||
|
void (*runBootloader)(void *arg);
|
||||||
|
|
||||||
|
// Read the function address from the ROM API tree.
|
||||||
|
runBootloaderAddress = **(uint32_t **)(0x1c00001c);
|
||||||
|
runBootloader = (void (*)(void * arg))runBootloaderAddress;
|
||||||
|
|
||||||
|
runBootloader(NULL);
|
||||||
|
}
|
||||||
@@ -1,11 +1,21 @@
|
|||||||
#ifndef __BOOTLOADER_H__
|
#ifndef __KBOOT_H__
|
||||||
#define __BOOTLOADER_H__
|
#define __KBOOT_H__
|
||||||
|
|
||||||
// Includes:
|
// Includes:
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
// Macros:
|
||||||
|
|
||||||
|
// bits for bootloader_config_t.enabledPeripherals
|
||||||
|
#define ENABLE_PERIPHERAL_UART (1<<0)
|
||||||
|
#define ENABLE_PERIPHERAL_I2C (1<<1)
|
||||||
|
#define ENABLE_PERIPHERAL_SPI (1<<2)
|
||||||
|
#define ENABLE_PERIPHERAL_CAN (1<<3)
|
||||||
|
#define ENABLE_PERIPHERAL_USB_HID (1<<4)
|
||||||
|
#define ENABLE_PERIPHERAL_USB_MSC (1<<7)
|
||||||
|
|
||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -24,9 +34,8 @@
|
|||||||
uint8_t clockDivider; // Inverted value of the divider to use for core and bus clocks when in high speed mode.
|
uint8_t clockDivider; // Inverted value of the divider to use for core and bus clocks when in high speed mode.
|
||||||
} bootloader_config_t;
|
} bootloader_config_t;
|
||||||
|
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
extern void JumpToBootloader(void);
|
extern void JumpToKboot(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user