2009-07-03 07:17:11 +08:00
|
|
|
/*
|
|
|
|
* File : start.S
|
|
|
|
* This file is part of RT-Thread RTOS
|
2012-02-16 12:19:20 +08:00
|
|
|
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
2009-07-03 07:17:11 +08:00
|
|
|
*
|
|
|
|
* The license and distribution terms for this file may be
|
|
|
|
* found in the file LICENSE in this distribution or at
|
2012-02-16 12:19:20 +08:00
|
|
|
* http://www.rt-thread.org/license/LICENSE
|
2009-07-03 07:17:11 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
2012-02-16 12:19:20 +08:00
|
|
|
* 2006-09-15 QiuYi The first version.
|
|
|
|
* 2012-02-15 aozima update.
|
2009-07-03 07:17:11 +08:00
|
|
|
*/
|
|
|
|
|
2012-02-16 12:19:20 +08:00
|
|
|
/* the magic number for the multiboot header. */
|
|
|
|
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
|
2009-07-03 07:17:11 +08:00
|
|
|
|
2012-02-16 12:19:20 +08:00
|
|
|
/* the flags for the multiboot header. */
|
|
|
|
#define MULTIBOOT_HEADER_FLAGS 0x00000003
|
|
|
|
|
|
|
|
#define CONFIG_STACKSIZE 8192
|
2009-07-03 07:17:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup I386
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
.section .init, "ax"
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
/* the system entry */
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
jmp multiboot_entry
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
/* Align 32 bits boundary. */
|
|
|
|
.align 4
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
/* multiboot header. */
|
|
|
|
multiboot_header:
|
|
|
|
/* magic */
|
|
|
|
.long MULTIBOOT_HEADER_MAGIC
|
|
|
|
/* flags */
|
|
|
|
.long MULTIBOOT_HEADER_FLAGS
|
|
|
|
/* checksum */
|
|
|
|
.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
multiboot_entry:
|
|
|
|
movl $(_end + 0x1000),%esp
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
/* reset eflags. */
|
|
|
|
pushl $0
|
|
|
|
popf
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
/*rebuild globe describe table*/
|
|
|
|
lgdt mygdtdesc
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
movl $0x10,%eax
|
|
|
|
movw %ax,%ds
|
|
|
|
movw %ax,%es
|
|
|
|
movw %ax,%ss
|
|
|
|
ljmp $0x08, $relocated
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
relocated:
|
|
|
|
/* push the pointer to the multiboot information structure. */
|
|
|
|
pushl %ebx
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
/* push the magic value. */
|
|
|
|
pushl %eax
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
call rtthread_startup
|
2012-02-16 12:19:20 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
/* never get here */
|
|
|
|
spin:
|
|
|
|
hlt
|
|
|
|
jmp spin
|
|
|
|
|
|
|
|
.data
|
|
|
|
.p2align 2
|
|
|
|
mygdt:
|
|
|
|
.word 0,0,0,0
|
|
|
|
|
|
|
|
.word 0x07FF /* 8Mb - limit=2047 */
|
|
|
|
.word 0x0000
|
|
|
|
.word 0x9A00 /* code read/exec */
|
|
|
|
.word 0x00C0
|
|
|
|
|
|
|
|
.word 0x07FF /* 8Mb - limit=2047 */
|
|
|
|
.word 0x0000
|
|
|
|
.word 0x9200 /* data read/write */
|
|
|
|
.word 0x00C0
|
|
|
|
|
|
|
|
mygdtdesc:
|
2012-02-16 12:19:20 +08:00
|
|
|
.word 0x17
|
2009-07-03 07:17:11 +08:00
|
|
|
.long mygdt
|
|
|
|
|
|
|
|
/*@}*/
|