📄 entry.c
字号:
/* * Initial C entry point of the boot loader. Called by the assembly * language setup code in boot.S/init.S. * * Copyright (c) 2000 Blue Mug, Inc. All Rights Reserved. * * We must have a stack pointer, but there are no other preconditions. * * The generated text for this file lives in the .hermit.boot section * of the loader executable. Symbols in the .hermit.boot section have * relocation addresses equal to their load addresses (see the link * map for details), so this section is designed to run from flash at * boot time. In GNU linker terminology, these symbols have VMA == * LMA ('info ld' for definitions). * * Pretty much all other symbols in the loader have VMAs within SRAM * or DRAM (depending on build configuration). This means that their * load addresses (LMAs) are not equal to their VMAs. Ergo most of * the loader must be relocated to RAM before it can run; we even * relocate the text segment to RAM, to make it possible to reprogram * the loader in flash. This file handles the relocation. * * Until the relocation is done, the loader won't be able to access * any writeable data (.data segment stuff) or use zeroed global * memory (.bss). Be careful when editing the code here! * * --miket */extern unsigned char __bss_start;extern unsigned char __bss_end;#ifdef RELOCATE#include <cs89712/ioregs.h>/* see loader.lds */extern unsigned char __text_start_flash;extern unsigned char __text_start;extern unsigned char __text_end;extern unsigned char __data_start_flash;extern unsigned char __data_start;extern unsigned char __data_end;void entry(void){ unsigned char *src, *dst; /* relocate .text */ src = &__text_start_flash; dst = &__text_start; while (dst < &__text_end) *dst++ = *src++; /* relocate .data */ src = &__data_start_flash; dst = &__data_start; while (dst < &__data_end) *dst++ = *src++; /* clear .bss */ dst = &__bss_start; while (dst < &__bss_end) *dst++ = 0; /* branch into relocated code */ __asm__ volatile ( " mov r0, #0x60000000\n" /* start of SRAM */ " mov pc, r0" /* go there */ );}#else/* see loader.c */extern void hmain(void);void entry(void){ unsigned char *dst; /* clear .bss */ dst = &__bss_start; while (dst < &__bss_end) *dst++ = 0; hmain();}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -