ArmLinux BOOTLOADER全程详解

网上关于LinuxBOOTLOADER文章不少了,但是大都是vivi,blob等比较庞大的程序,读起来不太方便,编译出的文件也比较大,而且更多的是面向开发用的引导代码,做成产品时还要裁减,这一定程度影响了开发速度,对初学者学习开销也比较大,在此分析一种简单的BOOTLOADER,是在三星公司提供的2410 BOOTLOADER上稍微修改后的结果,编译出来的文件大小不超过4k,希望对大家有所帮助.
1.几个重要的概念
COMPRESSED KERNEL and DECOMPRESSED KERNEL
压缩后的KERNEL,按照文档资料,现在不提倡使用DECOMPRESSED KERNEL,而要使用COMPRESSED KERNEL,它包括了解压器.因此要在ram分配时给压缩和解压的KERNEL提供足够空间,这样它们不会相互覆盖.当执行指令跳转到 COMPRESSED KERNEL后,解压器就开始工作,如果解压器探测到解压的代码会覆盖掉COMPRESSED KERNEL,那它会直接跳到COMPRESSED KERNEL后存放数据,并且重新定位KERNEL,所以如果没有足够空间,就会出错.

Jffs2 File System
可以使armlinux应用中产生的数据保存在FLASH上,我的板子还没用到这个.

RAMDISK
使用RAMDISK可以使ROOT FILE SYSTEM在没有其他设备的情况下启动.一般有两种加载方式,我就介绍最常用的吧,把COMPRESSED RAMDISK IMAGE放到指定地址,然后由BOOTLOADER把这个地址通过启动参数的方式ATAG_INITRD2传递给KERNEL.具体看代码分析.

启动参数(摘自IBM developer)
在调用内核之前,应该作一步准备工作,即:设置 Linux 内核的启动参数。Linux 2.4.x 以后的内核都期望以标记列表(tagged list)的形式来传递启动参数。启动参数标记列表以标记 ATAG_CORE 开始,以标记 ATAG_NONE 结束。每个标记由标识被传递参数的 tag_header 结构以及随后的参数值数据结构来组成。数据结构 tag 和 tag_header 定义在 Linux 内核源码的include/asm/setup.h 头文件中.
在嵌入式 Linux 系统中,通常需要由 BOOTLOADER 设置的常见启动参数有:ATAG_CORE、ATAG_MEM、ATAG_CMDLINE、ATAG_RAMDISK、ATAG_INITRD等。
(注)参数也可以用COMMANDLINE来设定,在我的BOOTLOADER里,我两种都用了.

2.开发环境和开发板配置:
CPU:S3C2410,BANK6上有64M的SDRAM(两块),BANK0上有32M NOR FLASH,串口当然是逃不掉的.这样,按照数据手册,地址分配如下:
0x4000_0000开始是4k的片内DRAM.
0x0000_0000开始是32M FLASH 16bit宽度
0x3000_0000开始是64M SDRAM 32bit宽度
注意:控制寄存器中的BANK6和BANK7部分必须相同.
0x4000_0000(片内DRAM)存放4k以内的BOOTLOADER IMAGE
0x3000_0100开始存放启动参数
0x3120_0000 存放COMPRESSED KERNEL IMAGE
0x3200_0000 存放COMPRESSED RAMDISK
0x3000_8000 指定为DECOMPRESSED KERNEL IMAGE ADDRESS
0x3040_0000 指定为DECOMPRESSED RAMDISK IMAGE ADDRESS
开发环境:Redhat Linux,armgcc toolchain, armlinux KERNEL
如何建立armgcc的编译环境:建议使用toolchain,而不要自己去编译armgcc,偶试过好多次,都以失败告终.
先下载arm-gcc 3.3.2 toolchain
将arm-linux-gcc-3.3.2.tar.bz2 解压到 /toolchain
# tar jxvf arm-linux-gcc-3.3.2.tar.bz2
# mv /usr/local/arm/3.3.2 /toolchain
在makefile 中在把arch=arm CROSS_COMPILE设置成toolchain的路径还有就是INCLUDE = -I ../include -I /root/my/usr/local/arm/3.3.2/include.,否则库函数就不能用了
3.启动方式:
可以放在FLASH里启动,或者用Jtag仿真器.由于使用NOR FLASH,根据2410的手册,片内的4K DRAM在不需要设置便可以直接使用,而其他存储器必须先初始化,比如告诉memory controller,BANK6里有两块SDRAM,数据宽度是32bit,= =.否则memory control会按照复位后的默认值来处理存储器.这样读写就会产生错误.
所以第一步,通过仿真器把执行代码放到0x4000_0000,(在编译的时候,设定TEXT_BASE=0x40000000)
第二步,通过 AxD把linux KERNEL IMAGE放到目标地址(SDRAM)中,等待调用
第三步,执行BOOTLOADER代码,从串口得到调试数据,引导armlinux

4.代码分析
讲了那么多执行的步骤,是想让大家对启动有个大概印象,接着就是BOOTLOADER内部的代码分析了,BOOTLOADER文章内容网上很多,我这里精简了下,删除了不必要的功能.
BOOTLOADER一般分为2部分,汇编部分和c语言部分,汇编部分执行简单的硬件初始化,C部分负责复制数据,设置启动参数,串口通信等功能.
BOOTLOADER的生命周期:
1. 初始化硬件,比如设置UART(至少设置一个),检测存储器= =.
2. 设置启动参数,这是为了告诉内核硬件的信息,比如用哪个启动界面,波特率 = =.
3. 跳转到Linux KERNEL的首地址.
4. 消亡
当然,在引导阶段,象vivi等,都用虚地址,如果你嫌烦的话,就用实地址,都一样.
我们来看代码:
2410init.s
.global _start//开始执行处
_start:
//下面是中断向量
b reset @ Supervisor Mode//重新启动后的跳转
⋯⋯
⋯⋯
reset:
ldr r0,=WTCON /WTCON地址为53000000,watchdog的控制寄存器 */
ldr r1,=0x0 /*关watchdog*/
str r1,[r0]
ldr r0,=INTMSK
ldr r1,=0xffffffff /*屏蔽所有中断*/
str r1,[r0]
ldr r0,=INTSUBMSK
ldr r1,=0x3ff /*子中断也一样*/
str r1,[r0]
/*Initialize Ports...for display LED.*/
ldr r0, =GPFCON
ldr r1, =0x55aa
str r1, [r0]
ldr r0, =GPFUP
ldr r1, =0xff
str r1, [r0]
ldr r0,=GPFDAT
ldr r1,=POWEROFFLED1
str r1,[r0]
/* Setup clock Divider control register
* you must configure CLKDIVN before LOCKTIME or MPLL UPLL
* because default CLKDIVN 1,1,1 set the SDMRAM Timing Conflictnop
* FCLK:HCLK:PCLK = 1:2:4 in this case
*/
ldr r0,=CLKDIVN
ldr r1,=0x3
str r1,[r0]
/*To reduce PLL lock time, adjust the LOCKTIME register. */
ldr r0,=LOCKTIME
ldr r1,=0xffffff
str r1,[r0]
/*Configure MPLL */
ldr r0,=MPLLCON
ldr r1,=((M_MDIV<<12)+(M_PDIV<<4)+M_SDIV) //Fin=12MHz,Fout=203MHz
str r1,[r0]
ldr r1,=GSTATUS2
ldr r10,[r1]
tst r10,#OFFRST
bne 1000f
//以上这段,我没动,就用三星写的了,下面是主要要改的地方
/* MEMORY C0NTROLLER(MC)设置*/
add r0,pc,#MCDATA - (.+8)// r0指向MCDATA地址,那里存放着MC初始化要用到的数据
ldr r1,=BWSCON // r1指向MC控制器寄存器的首地址
add r2,r0,#52 // 复制次数,偏移52字
1: //按照偏移量进行循环复制
ldr r3,[r0],#4
str r3,[r1],#4
cmp r2,r0
bne 1b
.align 2
MCDATA:
.word (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B5_BWSCON<<20)+(B6_BWSCON<<24)+(B7_BWSCON<<28))
上面这行就是BWSCON的数据,具体参数意义如下:
需要更改设置DW6 和DW7都设置成10,即32bit,DW0 设置成01,即16bit
下面都是每个BANK的控制器数据,大都是时钟相关,可以用默认值,设置完MC后,就跳到调用main函数的部分

.word ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+(B0_Tacp<<2)+(B0_PMC))
.word ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+(B1_Tacp<<2)+(B1_PMC))
.word ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+(B2_Tacp<<2)+(B2_PMC))
.word ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+(B3_Tacp<<2)+(B3_PMC))
.word ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+(B4_Tacp<<2)+(B4_PMC))
.word ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+(B5_Tacp<<2)+(B5_PMC))
.word ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN))
.word ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN))
.word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT)
.word 0xB2 /* REFRESH Control Register */
.word 0x30 /* BANKSIZE Register : Burst Mode */
.word 0x30 /* SDRAM Mode Register */
.align 2
.global call_main //调用main函数,函数参数都为0
call_main:
ldr sp,STACK_START
mov fp,#0 /* no previous frame, so fp=0*/
mov a1, #0 /* set argc to 0*/
mov a2, #0 /* set argv to NUL*/
bl main /* call main*/
STACK_START:
.word STACK_BASE
undefined_instruction:
software_interrupt:
prefetch_abort:
data_abort:
not_used:
irq:
fiq:

/*以上是主要的汇编部分,实现了时钟设置,串口设置watchdog关闭,中断关闭功能(如果有需要还可以降频使用),然后转入main*/

2410init.c file
int main(int argc,char **argv)
{
u32 test = 0;
void (*theKERNEL)(int zero, int arch, unsigned long params_addr) = (void (*)(int, int, unsigned long))RAM_COMPRESSED_KERNEL
_BASE; //压缩后的IMAGE地址
int i,k=0;
// downPt=(RAM_COMPRESSED_KERNEL_BASE);
chkBs=(_RAM_STARTADDRESS);//SDRAM开始的地方
// fromPt=(FLASH_LINUXKERNEL);
MMU_EnableICache();
ChangeClockDivider(1,1); // 1:2:4
ChangeMPllValue(M_MDIV,M_PDIV,M_SDIV); //Fin=12MHz FCLK=200MHz
Port_Init();//设置I/O端口,在使用com口前,必须调用这个函数,否则通信芯片根本得不到数据
Uart_Init(PCLK, 115200);//PCLK使用默认的200000,拨特率115200
/*******************(检查ram空间)*******************/
Uart_SendString("ntLinux S3C2410 Nor BOOTLOADERn");
Uart_SendString("ntChecking SDRAM 2410loader.c...n");
for(;chkBs<0x33FA0140;chkBs=chkBs+0x4,test++)//

//根据我的经验,最好以一个字节为递增,我们的板子,在256byte递增检测的时候是没问题的,但是
//以1byte递增就出错了,第13跟数据线随几的会冒”1”,检测出来是硬件问题,现象如下
//用仿真器下代码测试SDRAM,开始没贴28F128A3J FLASH片子,测试结果很好,但在上了FLASH片子//之后,测试数据(data)为0x00000400
连续成批写入读出时,操作大约1k左右内存空间就会出错,//而且随机。那个出错数据总是变为0x00002400,数据总线10位和13位又没短路
发生。用其他数据//测试比如0x00000200;0x00000800没这问题。dx帮忙。
//至今没有解决,所以我用不了Flash.
{
chkPt1 = chkBs;
*(u32 *)chkPt1 = test;//写数据
if(*(u32 *)chkPt1==1024))//读数据和写入的是否一样?
{
chkPt1 += 4;
Led_Display(1);
Led_Display(2);
Led_Display(3);
Led_Display(4);
}
else
goto error;
}
Uart_SendString("ntSDRAM Check Successful!ntMemory Maping...");
get_memory_map();
//获得可用memory 信息,做成列表,后面会作为启动参数传给KERNEL
//所谓内存映射就是指在4GB 物理地址空间中有哪些地址范围被分配用来寻址系统的 RAM 单元。
Uart_SendString("ntMemory Map Successful!n");
//我用仿真器把KERNEL,RAMDISK直接放在SDRAM上,所以下面这段是不需要的,但是如果KERNEL,RAMDISK在FLASH里,那就需要.

/*******************(copy linux KERNEL)*******************/
Uart_SendString("tLoading KERNEL IMAGE from FLASH... n ");
Uart_SendString("tand copy KERNEL IMAGE to SDRAM at 0x31000000n");
Uart_SendString("ttby LEIJUN DONG dongleijun4000@hotmail.com n");
for(k = 0;k < 196608;k++,downPt += 1,fromPt += 1)//3*1024*1024/32linux KERNEL des,src,length=3M
* (u32 *)downPt = * (u32 *)fromPt;
/*******************(load RAMDISK)*******************/
Uart_SendString("ttloading COMPRESSED RAMDISK...n");
downPt=(RAM_COMPRESSED_RAMDISK_BASE);
fromPt=(FLASH_RAMDISK_BASE);
for(k = 0;k < 196608;k++,downPt += 1,fromPt += 1)//3*1024*1024/32linux KERNEL des,src,length=3M
* (u32 *)downPt = * (u32 *)fromPt;
/******jffs2文件系统,在开发中如果用不到FLASH,这段也可以不要********/
Uart_SendString("ttloading jffs2...n");
downPt=(RAM_JFFS2);
fromPt=(FLASH_JFFS2);
for(k = 0;k < (1024*1024/32);k++,downPt += 1,fromPt += 1)
* (u32 *)downPt = * (u32 *)fromPt;
Uart_SendString( "Load Success...Run...n ");
/*******************(setup param)*******************/
setup_start_tag();//开始设置启动参数
setup_memory_tags();//内存印象
setup_commandline_tag("console=ttyS0,115200n8");//启动命令行
setup_initrd2_tag();//root device
setup_RAMDISK_tag();//ramdisk image
setup_end_tag();
/*关I-cache */
asm ("mrc p15, 0, %0, c1, c0, 0": "=r" (i));
i &= ~0x1000;
asm ("mcr p15, 0, %0, c1, c0, 0": : "r" (i));
/* flush I-cache */
asm ("mcr p15, 0, %0, c7, c5, 0": : "r" (i));

//下面这行就跳到了COMPRESSED KERNEL的首地址
theKERNEL(0, ARCH_NUMBER, (unsigned long *)(RAM_BOOT_PARAMS));
//启动kernel时候,I-cache可以开也可以关,r0必须是0,r1必须是CPU型号
(可以从linux/arch/arm/tools/mach-types中找到),r2必须是参数的物理开始地址

/*******************END*******************/
error:
Uart_SendString("nnPanic SDRAM check error!n");
return 0;
}
static void setup_start_tag(void)
{
params = (struct tag *)RAM_BOOT_PARAMS;//启动参数开始的地址
params->hdr.tag = ATAG_CORE;
params->hdr.size = tag_size(tag_core);
params->u.core.flags = 0;
params->u.core.pagesize = 0;
params->u.core.rootdev = 0;
params = tag_next(params);
}
static void setup_memory_tags(void)
{
int i;
for(i = 0; i < NUM_MEM_AREAS; i++) {
if(memory_map[i].used) {
params->hdr.tag = ATAG_MEM;
params->hdr.size = tag_size(tag_mem32);
params->u.mem.start = memory_map[i].start;
params->u.mem.size = memory_map[i].len;
params = tag_next(params);
}
}
}
static void setup_commandline_tag(char *commandline)
{
int i = 0;
/* skip non-existent command lines so the kernel will still
* use its default command line.
*/
params->hdr.tag = ATAG_CMDLINE;
params->hdr.size = 8;
//console=ttyS0,115200n8
strcpy(params->u.cmdline.cmdline, p);
params = tag_next(params);
}
static void setup_initrd2_tag(void)
{
/* an ATAG_INITRD node tells the kernel where the compressed
* ramdisk can be found. ATAG_RDIMG is a better name, actually.
*/
params->hdr.tag = ATAG_INITRD2;
params->hdr.size = tag_size(tag_initrd);
params->u.initrd.start = RAM_COMPRESSED_RAMDISK_BASE;
params->u.initrd.size = 2047;//k byte
params = tag_next(params);
}
static void setup_ramdisk_tag(void)
{
/* an ATAG_RAMDISK node tells the kernel how large the
* decompressed ramdisk will become.
*/
params->hdr.tag = ATAG_RAMDISK;
params->hdr.size = tag_size(tag_ramdisk);
params->u.ramdisk.start = RAM_DECOMPRESSED_RAMDISK_BASE;
params->u.ramdisk.size = 7.8*1024; //k byte
params->u.ramdisk.flags = 1; // automatically load ramdisk
params = tag_next(params);
}
static void setup_end_tag(void)
{
params->hdr.tag = ATAG_NONE;
params->hdr.size = 0;
} void Uart_Init(int pclk,int baud)//串口是很重要的
{
int i;
if(pclk == 0)
pclk = PCLK;
rUFCON0 = 0x0; //UART channel 0 FIFO control register, FIFO dISAble
rUMCON0 = 0x0; //UART chaneel 0 MODEM control register, AFC dISAble
//UART0
rULCON0 = 0x3; //Line control register : Normal,No parity,1 stop,8 bits
下面这段samsung好象写的不太对,但是我按照Normal,No parity,1 stop,8 bits算出来的确是0x245
// [10] [9] [8] [7] [6] [5] [4] [3:2] [1:0]
// Clock Sel, Tx Int, Rx Int, Rx Time Out, Rx err, Loop-back, Send break, Transmit Mode, Receive Mode
// 0 1 0 , 0 1 0 0 , 01 01
// PCLK Level Pulse DISAble Generate Normal Normal Interrupt or Polling
rUCON0 = 0x245; // Control register
rUBRDIV0=( (int)(PCLK/16./ baud) -1 ); //Baud rate divisior register 0
delay(10);
}

经过以上的折腾,接下来就是kernel的活了.能不能启动kernel,得看你编译kernel的水平了. 

摘自:http://www.dz863.com/Embedded-Systems-Design/ARM-Microcontroller/ArmLinux-BOOTLOADER.htm


 
棉花糖糖主 @ 2006-02-02 10:25


		Kernel Memory Layout on ARM Linux
            Russell King <rmk@arm.linux.org.uk>
            November 17, 2005 (2.6.15)
            This document describes the virtual memory layout which the Linux
            kernel uses for ARM processors.  It indicates which regions are
            free for platforms to use, and which are used by generic code.
            The ARM CPU is capable of addressing a maximum of 4GB virtual memory
            space, and this must be shared between user space processes, the
            kernel, and hardware devices.
            As the ARM architecture matures, it becomes necessary to reserve
            certain regions of VM space for use for new facilities; therefore
            this document may reserve more VM space over time.
            Start		End		Use
            --------------------------------------------------------------------------
            ffff8000	ffffffff	copy_user_page / clear_user_page use.
            For SA11xx and Xscale, this is used to
            setup a minicache mapping.
            ffff1000	ffff7fff	Reserved.
            Platforms must not use this address range.
            ffff0000	ffff0fff	CPU vector page.
            The CPU vectors are mapped here if the
            CPU supports vector relocation (control
            register V bit.)
            ffc00000	fffeffff	DMA memory mapping region.  Memory returned
            by the dma_alloc_xxx functions will be
            dynamically mapped here.
            ff000000	ffbfffff	Reserved for future expansion of DMA
            mapping region.
            VMALLOC_END	feffffff	Free for platform use, recommended.
            VMALLOC_END must be aligned to a 2MB
            boundary.
            VMALLOC_START	VMALLOC_END-1	vmalloc() / ioremap() space.
            Memory returned by vmalloc/ioremap will
            be dynamically placed in this region.
            VMALLOC_START may be based upon the value
            of the high_memory variable.
            PAGE_OFFSET	high_memory-1	Kernel direct-mapped RAM region.
            This maps the platforms RAM, and typically
            maps all platform RAM in a 1:1 relationship.
            TASK_SIZE	PAGE_OFFSET-1	Kernel module space
            Kernel modules inserted via insmod are
            placed here using dynamic mappings.
            00001000	TASK_SIZE-1	User space mappings
            Per-thread mappings are placed here via
            the mmap() system call.
            00000000	00000fff	CPU vector page / null pointer trap
            CPUs which do not support vector remapping
            place their vector page here.  NULL pointer
            dereferences by both the kernel and user
            space are also caught via this mapping.
            Please note that mappings which collide with the above areas may result
            in a non-bootable kernel, or may cause the kernel to (eventually) panic
            at run time.
            Since future CPUs may impact the kernel mapping layout, user programs
            must not access any memory which is not mapped inside their 0x0001000
            to TASK_SIZE address range.  If they wish to access these areas, they
            must set up their own mappings using open() and mmap().
            


摘自:http://www.arm.linux.org.uk/developer/memory.txt


 
棉花糖糖主 @ 2006-02-02 10:11

Booting ARM Linux

Author: Russell King
Initial date: May 18, 2002
Revision: 1 - 17 September 20042 - 30 September 2004

In order to boot ARM Linux, you require a boot loader, which is a small program that runs before the main kernel. The boot loader is expected to initialise various devices, and eventually call the Linux kernel, passing information to the kernel.

Essentially, the boot loader should provide (as a minimum) the following:

  1. Setup and initialise the RAM.
  2. Initialise one serial port.
  3. Detect the machine type.
  4. Setup the kernel tagged list.
  5. Call the kernel image.
1. Setup and initialise RAM

Existing boot loaders: MANDATORY
New boot loaders: MANDATORY

The boot loader is expected to find and initialise all RAM that the kernel will use for volatile data storage in the system. It performs this in a machine dependent manner. (It may use internal algorithms to automatically locate and size all RAM, or it may use knowledge of the RAM in the machine, or any other method the boot loader designer sees fit.)

2. Initialise one serial port

Existing boot loaders: OPTIONAL, RECOMMENDED
New boot loaders: OPTIONAL, RECOMMENDED

The boot loader should initialise and enable one serial port on the target. This allows the kernel serial driver to automatically detect which serial port it should use for the kernel console (generally used for debugging purposes, or communication with the target.)

As an alternative, the boot loader can pass the relevant 'console=' option to the kernel via the tagged lists specifing the port, and serial format options as described in

linux/Documentation/kernel-parameters.txt.

3. Detect the machine type

Existing boot loaders: OPTIONAL
New boot loaders: MANDATORY

The boot loader should detect the machine type its running on by some method. Whether this is a hard coded value or some algorithm that looks at the connected hardware is beyond the scope of this document. The boot loader must ultimately be able to provide a MACH_TYPE_xxx value to the kernel. (see linux/arch/arm/tools/mach-types).

4. Setup the kernel tagged list

Existing boot loaders: OPTIONAL, HIGHLY RECOMMENDED
New boot loaders: MANDATORY

The boot loader must create and initialise the kernel tagged list. A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE. The ATAG_CORE tag may or may not be empty. An empty ATAG_CORE tag has the size field set to '2' (0x00000002). The ATAG_NONE must set the size field to zero.

Any number of tags can be placed in the list. It is undefined whether a repeated tag appends to the information carried by the previous tag, or whether it replaces the information in its entirety; some tags behave as the former, others the latter.

The boot loader must pass at a minimum the size and location of the system memory, and root filesystem location. Therefore, the minimum tagged list should look:

 

	+-----------+
            base ->	| ATAG_CORE |  |
            +-----------+  |
            | ATAG_MEM  |  | increasing address
            +-----------+  |
            | ATAG_NONE |  |
            +-----------+  v
            
The tagged list should be stored in system RAM.

The tagged list must be placed in a region of memory where neither the kernel decompressor nor initrd 'bootp' program will overwrite it. The recommended placement is in the first 16KiB of RAM.

5. Calling the kernel image

Existing boot loaders: MANDATORY
New boot loaders: MANDATORY

There are two options for calling the kernel zImage. If the zImage is stored in flash, and is linked correctly to be run from flash, then it is legal for the boot loader to call the zImage in flash directly.

The zImage may also be placed in system RAM (at any location) and called there. Note that the kernel uses 16K of RAM below the image to store page tables. The recommended placement is 32KiB into RAM.

In either case, the following conditions must be met:

  • CPU register settings
    • r0 = 0.
    • r1 = machine type number discovered in (3) above.
    • r2 = physical address of tagged list in system RAM.
  • CPU mode
    • All forms of interrupts must be disabled (IRQs and FIQs.)
    • The CPU must be in SVC mode. (A special exception exists for Angel.)
  • Caches, MMUs
    • The MMU must be off.
    • Instruction cache may be on or off.
    • Data cache must be off and must not contain any stale data.
  • Devices
    • DMA to/from devices should be quiesced.
  • The boot loader is expected to call the kernel image by jumping directly to the first instruction of the kernel image.