2 FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
\r
13 ***************************************************************************
\r
14 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
15 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
16 >>! obliged to provide the source code for proprietary components !<<
\r
17 >>! outside of the FreeRTOS kernel. !<<
\r
18 ***************************************************************************
\r
20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
23 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * FreeRTOS provides completely free yet professionally developed, *
\r
28 * robust, strictly quality controlled, supported, and cross *
\r
29 * platform software that is more than just the market leader, it *
\r
30 * is the industry's de facto standard. *
\r
32 * Help yourself get started quickly while simultaneously helping *
\r
33 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
34 * tutorial book, reference manual, or both: *
\r
35 * http://www.FreeRTOS.org/Documentation *
\r
37 ***************************************************************************
\r
39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
\r
40 the FAQ page "My application does not run, what could be wrong?". Have you
\r
41 defined configASSERT()?
\r
43 http://www.FreeRTOS.org/support - In return for receiving this top quality
\r
44 embedded software for free we request you assist our global community by
\r
45 participating in the support forum.
\r
47 http://www.FreeRTOS.org/training - Investing in training allows your team to
\r
48 be as productive as possible as early as possible. Now you can receive
\r
49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
\r
50 Ltd, and the world's leading authority on the world's leading RTOS.
\r
52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
\r
60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
61 licenses offer ticketed support, indemnification and commercial middleware.
\r
63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
64 engineered and independently SIL3 certified version for use in safety and
\r
65 mission critical applications that require provable dependability.
\r
70 /* Set to 1 to enable functionality */
\r
71 #define __SHOW_KERNEL_PARAMS__ 0
\r
73 /* Local definitions boot loader */
\r
74 #define MULTIBOOT_SIGNATURE 0x2BADB002
\r
75 #define MULTIBOOT_BOOTINFO_MMAP 0x00000040
\r
77 /* Local definitions for GD table */
\r
78 #define GDT_ENTRIES 8
\r
79 #define GDT_ENTRY_SIZE 8
\r
80 #define GDT_BYTES (GDT_ENTRIES * GDT_ENTRY_SIZE)
\r
82 /* Globals and externs */
\r
90 .extern __text_start
\r
94 .extern __data_start
\r
98 .extern __stack_for_main
\r
100 .global __text_start
\r
104 .global __data_start
\r
106 .global __bss_start
\r
111 .extern kernel_load_check
\r
114 /* Local constants for multiboot section */
\r
115 .set ALIGN, 1<<0 /* align loaded modules on page boundaries */
\r
116 .set MEMINFO, 1<<1 /* provide memory map */
\r
117 .set MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */
\r
118 .set FLAGS, ALIGN|MEMINFO /* this is the multiboot 'flag' field */
\r
119 .set CHECKSUM, -(MAGIC + FLAGS) /* checksum of above */
\r
126 gdt: .space GDT_BYTES
\r
127 gdtr: .word (GDT_BYTES-1) /* sizeof _gdt -1 (in bytes) */
\r
128 .long gdt /* global pointer to the gdt */
\r
130 /* Start of application text */
\r
131 .section .text.entry
\r
133 /* Skip mb header */
\r
137 /* Multiboot header */
\r
139 .long MAGIC /* offset = 0 */
\r
140 .long FLAGS /* offset = 4 */
\r
141 .long CHECKSUM /* offset = 8 */
\r
142 .long _mboot_hdr /* should be header address - offset = 12 */
\r
143 .long __text_start /* load address (start of text) - offset = 16 */
\r
144 .long __bss_start /* load end address (end of data) - offset = 20*/
\r
145 .long __bss_end /* bss end address - offset = 24*/
\r
146 .long _start /* entry_addr - offset = 28*/
\r
148 /* Start of executable code */
\r
151 /* Store boot arguments */
\r
152 movl %eax, bootsign
\r
153 movl %ebx, bootinfo
\r
155 /* Check to see if kernel is bootstrapped by grub */
\r
156 cmpl $MULTIBOOT_SIGNATURE, %eax
\r
158 testb $MULTIBOOT_BOOTINFO_MMAP, (%ebx)
\r
163 /* Initialise the stack pointer */
\r
164 movl $__stack_for_main, %esp
\r
166 /* Reset EFLAGS. */
\r
170 /* Set up the global descriptor table */
\r
173 ljmp $0x8, $gdt1 /* CS descriptor 1 */
\r
175 movl $0x10, %eax /* DS descriptor 2 */
\r
180 movl $0x18, %eax /* SS descriptor 3 */
\r
183 /* Clear interrupt flag */
\r
186 /* Initialise platform */
\r
189 /* Show kernel parameters and call main, or just call main */
\r
190 #if (__SHOW_KERNEL_PARAMS__ == 1)
\r
191 /*---------------------------------------------------------------------
\r
192 On successful OS load EAX should contain 0x2BADB002
\r
193 EBX should contain the physical address of multiboot info structure
\r
195 Push the pointers to the multiboot information structure
\r
196 and the magic number on the stack and check values returned
\r
197 ----------------------------------------------------------------------*/
\r
198 movl bootsign, %eax
\r
199 movl bootinfo, %ebx
\r
200 pushl %ebx /* Multiboot information */
\r
201 pushl %eax /* Magic number */
\r
202 call show_kernel_parameters
\r
204 /*---------------------------------------------------------------------
\r
205 Call main() routine
\r
206 ----------------------------------------------------------------------*/
\r
210 /* Should not get here, but just in case - loop forever */
\r
216 /*-------------------------------------------------------------------------
\r
217 GLOBAL ASSEMBLY LANGUAGE ROUTINES
\r
218 --------------------------------------------------------------------------*/
\r
228 inb: movl 4(%esp), %edx
\r
229 xorl %eax, %eax # clr eax
\r
235 inw: movl 4(%esp), %edx
\r
236 xorl %eax, %eax # clr eax
\r
242 inl: movl 4(%esp), %edx
\r
249 outb: movl 4(%esp), %edx
\r
256 outw: movl 4(%esp), %edx
\r
263 outl: movl 4(%esp), %edx
\r