forked from raburton/rboot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rboot-private.h
75 lines (61 loc) · 1.75 KB
/
rboot-private.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef __RBOOT_PRIVATE_H__
#define __RBOOT_PRIVATE_H__
//////////////////////////////////////////////////
// rBoot open source boot loader for ESP8266.
// Copyright 2015 Richard A Burton
// See license.txt for license terms.
//////////////////////////////////////////////////
typedef int int32;
typedef unsigned int uint32;
typedef unsigned char uint8;
#include <rboot.h>
#define NOINLINE __attribute__ ((noinline))
#define ROM_MAGIC 0xe9
#define ROM_MAGIC_NEW1 0xea
#define ROM_MAGIC_NEW2 0x04
#define TRUE 1
#define FALSE 0
// buffer size, must be at least 0x10 (size of rom_header_new structure)
#define BUFFER_SIZE 0x100
// stage2 read chunk maximum size (limit for SPIRead)
#define READ_SIZE 0x1000
// esp8266 built in rom functions
extern uint32 SPIRead(uint32 addr, void *outptr, uint32 len);
extern uint32 SPIEraseSector(int);
extern uint32 SPIWrite(uint32 addr, void *inptr, uint32 len);
extern void ets_printf(char*, ...);
extern void ets_delay_us(int);
extern void ets_memset(void*, uint8, uint32);
extern void ets_memcpy(void*, const void*, uint32);
// functions we'll call by address
typedef void stage2a(uint32);
typedef void usercode(void);
// standard rom header
typedef struct {
// general rom header
uint8 magic;
uint8 count;
uint8 flags1;
uint8 flags2;
usercode* entry;
} rom_header;
typedef struct {
uint8* address;
uint32 length;
} section_header;
// new rom header (irom section first) there is
// another 8 byte header straight afterward the
// standard header
typedef struct {
// general rom header
uint8 magic;
uint8 count; // second magic for new header
uint8 flags1;
uint8 flags2;
uint32 entry;
// new type rom, lib header
uint32 add; // zero
uint32 len; // length of irom section
} rom_header_new;
#endif