entry.c

来自「Hermit-at-1.1.3,一款bootloader」· C语言 代码 · 共 55 行

C
55
字号
/* * Initial C entry point of the boot loader.  Called by the assembly * language setup code in boot.S/init.S. * * Copyright (c) 2004 Atmark Techno, Inc. All Rights Reserved. * * Based on: * 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 */#include <target/mem.h>extern unsigned char __bss_start;extern unsigned char __bss_end;/* 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;extern int hmain(void);void entry(void){	/* clear .bss */        memset(&__bss_start, 0, &__bss_end - &__bss_start);        hmain();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?