1/* 2 * File : start.S 3 * This file is part of RT-Thread RTOS 4 * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team 5 * 6 * The license and distribution terms for this file may be 7 * found in the file LICENSE in this distribution or at 8 * http://www.rt-thread.org/license/LICENSE 9 * 10 * Change Logs: 11 * Date Author Notes 12 * 2006-09-15 QiuYi The first version. 13 * 2012-02-15 aozima update. 14 */ 15 16/* the magic number for the multiboot header. */ 17#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 18 19/* the flags for the multiboot header. */ 20#define MULTIBOOT_HEADER_FLAGS 0x00000003 21 22#define CONFIG_STACKSIZE 8192 23 24/** 25 * @addtogroup I386 26 */ 27/*@{*/ 28 29.section .init, "ax" 30 31/* the system entry */ 32.globl _start 33_start: 34 jmp multiboot_entry 35 36 /* Align 32 bits boundary. */ 37 .align 4 38 39 /* multiboot header. */ 40multiboot_header: 41 /* magic */ 42 .long MULTIBOOT_HEADER_MAGIC 43 /* flags */ 44 .long MULTIBOOT_HEADER_FLAGS 45 /* checksum */ 46 .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) 47 48multiboot_entry: 49 movl $(_end + 0x1000),%esp 50 51 /* reset eflags. */ 52 pushl $0 53 popf 54 55 /*rebuild globe describe table*/ 56 lgdt mygdtdesc 57 58 movl $0x10,%eax 59 movw %ax,%ds 60 movw %ax,%es 61 movw %ax,%ss 62 ljmp $0x08, $relocated 63 64relocated: 65 /* push the pointer to the multiboot information structure. */ 66 pushl %ebx 67 68 /* push the magic value. */ 69 pushl %eax 70 71 call rtthread_startup 72 73 /* never get here */ 74spin: 75 hlt 76 jmp spin 77 78.data 79.p2align 2 80mygdt: 81 .word 0,0,0,0 82 83 .word 0x07FF /* 8Mb - limit=2047 */ 84 .word 0x0000 85 .word 0x9A00 /* code read/exec */ 86 .word 0x00C0 87 88 .word 0x07FF /* 8Mb - limit=2047 */ 89 .word 0x0000 90 .word 0x9200 /* data read/write */ 91 .word 0x00C0 92 93mygdtdesc: 94 .word 0x17 95 .long mygdt 96 97/*@}*/ 98