24 #define LOAD_ADDR 0x00100000 25 extern int ByteSet(
void *buf,
int c,
size_t len);
51 uint32_t drives_length;
54 uint32_t config_table;
56 uint32_t boot_loader_name;
60 uint32_t vbe_control_info;
61 uint32_t vbe_mode_info;
63 uint32_t vbe_interface_seg;
64 uint32_t vbe_interface_off;
65 uint32_t vbe_interface_len;
68 inline void writeChar(
char c)
70 #if defined(ARM_VERSATILE) 71 volatile char *p =
reinterpret_cast<volatile char *
>(0x101f1000);
72 #elif defined(ARM_INTEGRATOR) 73 volatile char *p =
reinterpret_cast<volatile char *
>(0x16000000);
75 #error No valid ARM board! 78 asm volatile(
"" :::
"memory");
79 #ifndef SERIAL_IS_FILE 81 asm volatile(
"" :::
"memory");
85 inline void writeStr(
const char *str)
92 void writeHex(
unsigned int n)
98 for (i = 28; i > 0; i -= 4)
100 tmp = (n >> i) & 0xF;
101 if (tmp == 0 && noZeroes)
109 writeChar(tmp - 0xA +
'a');
114 writeChar(tmp +
'0');
121 writeChar(tmp - 0xA +
'a');
125 writeChar(tmp +
'0');
129 extern "C" void __start();
130 extern "C" void start()
134 asm volatile(
"mov sp,$0x10000; mov ip, sp; b __start");
139 extern "C" void arm_swint_handler()
143 asm volatile(
"mov %0, lr" :
"=r"(intnum));
145 writeStr(
"Link register: ");
147 writeHex(0xdeadbeef);
152 writeStr(
"softint\r\n");
158 writeStr(
"SWI01\r\n");
166 extern "C" void arm_instundef_handler()
168 writeStr(
"undefined instruction!\n");
173 extern "C" void arm_fiq_handler()
180 extern "C" void arm_irq_handler()
187 extern "C" void arm_reset_handler()
189 writeStr(
"reset\r\n");
194 extern "C" void __arm_vector_table();
196 uint32_t arm_get_cpsr()
199 asm volatile(
"msr cpsr,r0" :
"=r"(ret));
203 void MemoryCopy(
void *dest,
const void *src,
size_t len);
205 extern "C" void __start()
209 MemoryCopy((
void *) 0, (
void *) __arm_vector_table, (4 * 8) + (4 * 6));
212 writeStr(
"about to do software interrupt\r\n");
213 asm volatile(
"swi #1");
214 writeStr(
"swi done and returned\r\n");
216 writeStr(
"Loading kernel...\r\n");
219 elf.
load((uint8_t *) file, 0);
226 ByteSet(&bs, 0,
sizeof(bs));
227 bs.shndx = elf.m_pHeader->shstrndx;
228 bs.num = elf.m_pHeader->shnum;
229 bs.size = elf.m_pHeader->shentsize;
230 bs.addr = (
unsigned int) elf.m_pSectionHeaders;
233 for (
int i = 0; i < elf.m_pHeader->shnum; i++)
235 elf.m_pSectionHeaders[i].addr =
236 elf.m_pSectionHeaders[i].offset + (uint32_t) elf.
m_pBuffer;
239 writeStr(
"Kernel loaded, jumping to entry point...\r\n");
243 writeStr(
"Kernel returned\r\n");
Bootstrap structure passed to the kernel entry point.
uint8_t * m_pBuffer
Offset of the file in memory.
bool load(uint8_t *pBuffer, unsigned int nBufferLength)