changeset 440:d2722bc50510

* src/plf_stub.c: Removed redundant reinitialization of VSR table in hal_pc_stubs_init(). This has already been done in hal_platform_init() and reinitializing here destroys the FPU switch VSR. * src/plf_misc.c (hal_platform_init): Added configuration and test to avoid overwriting the FPU switch VSR with the default VSR. This caused problems with stand-alone application that use lazy FPU switching. Moved call to hal_ctrlc_isr_init() to after call to hal_if_init(). Previously, stand-alone applications had problems with ctrl-c handling because the CALL_HACK stuff didn't work. * cdl/hal_i386_pc.cdl: Added GRUB startup option. This enables support for booting from the GRUB bootloader. Added CYGDBG_HAL_DEBUG_GDB_INITIAL_BREAK option to force a breakpoint just before calling cyg_start(). This is insinuated into the CYGPKG_HAL_DEBUG part of the tree, and conditioned to only work for stand-alone apps with the stubs included. * include/platform.inc: Added GRUB startup support. * include/pkgconf/mlt_i386_pc_grub.mlt: * include/pkgconf/mlt_i386_pc_grub.ldi: * include/pkgconf/mlt_i386_pc_grub.h: Added these MLT files to support the new GRUB startup option. * misc/menu.lst: Added this example GRUB menu configuration file.
author nickg
date Sun, 01 Dec 2002 15:48:34 +0000
parents 3e3067d83e1f
children 41489edbdf76
files packages/hal/i386/pc/current/ChangeLog packages/hal/i386/pc/current/cdl/hal_i386_pc.cdl packages/hal/i386/pc/current/include/pkgconf/mlt_i386_pc_grub.h packages/hal/i386/pc/current/include/pkgconf/mlt_i386_pc_grub.ldi packages/hal/i386/pc/current/include/pkgconf/mlt_i386_pc_grub.mlt packages/hal/i386/pc/current/include/platform.inc packages/hal/i386/pc/current/misc/menu.lst packages/hal/i386/pc/current/src/plf_misc.c packages/hal/i386/pc/current/src/plf_stub.c
diffstat 9 files changed, 217 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/i386/pc/current/ChangeLog
+++ b/packages/hal/i386/pc/current/ChangeLog
@@ -1,3 +1,35 @@
+2002-11-28  Nick Garnett  <nickg@ecoscentric.com>
+
+	* src/plf_stub.c: Removed redundant reinitialization of VSR table
+	in hal_pc_stubs_init(). This has already been done in
+	hal_platform_init() and reinitializing here destroys the FPU
+	switch VSR.
+
+	* src/plf_misc.c (hal_platform_init):
+	Added configuration and test to avoid overwriting the FPU switch
+	VSR with the default VSR. This caused problems with stand-alone
+	application that use lazy FPU switching.
+	Moved call to hal_ctrlc_isr_init() to after call to
+	hal_if_init(). Previously, stand-alone applications had problems
+	with ctrl-c handling because the CALL_HACK stuff didn't work.
+
+	* cdl/hal_i386_pc.cdl:
+	Added GRUB startup option. This enables support for booting from
+	the GRUB bootloader.
+	Added CYGDBG_HAL_DEBUG_GDB_INITIAL_BREAK option to force a
+	breakpoint just before calling cyg_start(). This is insinuated
+	into the CYGPKG_HAL_DEBUG part of the tree, and conditioned to
+	only work for stand-alone apps with the stubs included.
+
+	* include/platform.inc: Added GRUB startup support.
+
+	* include/pkgconf/mlt_i386_pc_grub.mlt: 
+	* include/pkgconf/mlt_i386_pc_grub.ldi: 
+	* include/pkgconf/mlt_i386_pc_grub.h: 
+	Added these MLT files to support the new GRUB startup option.
+
+	* misc/menu.lst: Added this example GRUB menu configuration file.
+	
 2002-05-07  Gary Thomas  <gthomas@redhat.com>
 
 	* cdl/hal_i386_pc.cdl: 
--- a/packages/hal/i386/pc/current/cdl/hal_i386_pc.cdl
+++ b/packages/hal/i386/pc/current/cdl/hal_i386_pc.cdl
@@ -79,20 +79,33 @@ cdl_package CYGPKG_HAL_I386_PC {
     cdl_component CYG_HAL_STARTUP {
         display       "Startup type"
         flavor        data
-        legal_values  {"RAM" "FLOPPY" "ROM"}
+        legal_values  {"RAM" "FLOPPY" "ROM" "GRUB"}
         default_value {"RAM"}
 	no_define
 	define -file system.h CYG_HAL_STARTUP
         description   "
-            It is possible to configure eCos for the PC target to build for
+            It is possible to configure eCos for the PC target to build for:
             RAM startup (generally when being run under an existing
-            Monitor program like RedBoot), FLOPPY startup (for writing
+            Monitor program like RedBoot); FLOPPY startup (for writing
             to a floppy disk, which can then be used for booting
-            on PCs with a standard BIOS), or ROM startup (for writing
+            on PCs with a standard BIOS), GRUB startup (for being booted
+            by the GRUB bootloader) ROM startup (for writing
             straight to a boot ROM/Flash). ROM startup is experimental
             at this time."
     }
-        
+
+    cdl_option CYGDBG_HAL_DEBUG_GDB_INITIAL_BREAK {
+        display    "Enable initial breakpoint"
+        parent     CYGPKG_HAL_DEBUG
+        active_if  CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
+        default_value { !CYGPKG_REDBOOT }
+        description "
+                This option causes an application that has GDB stubs built in
+                to take a breakpoint immediately before calling cyg_start().
+                This gives the developer a chance to set any breakpoints or
+                inspect the system state before it proceeds."
+    }
+
     cdl_option CYGBLD_BUILD_I386_ROMBOOT {
 	display       "Build ROM bootstrap code"
 	calculated    { CYG_HAL_STARTUP == "ROM" }
@@ -257,18 +270,20 @@ cdl_package CYGPKG_HAL_I386_PC {
         display "Memory layout"
         flavor data
         no_define
-        calculated { CYG_HAL_STARTUP == "RAM" ? "i386_pc_ram" : \
-		     CYG_HAL_STARTUP == "ROM" ? "i386_pc_rom" : \
-	                                        "i386_pc_floppy" }
+        calculated { CYG_HAL_STARTUP == "RAM"  ? "i386_pc_ram" : \
+		     CYG_HAL_STARTUP == "ROM"  ? "i386_pc_rom" : \
+		     CYG_HAL_STARTUP == "GRUB" ? "i386_pc_grub" : \
+	                                         "i386_pc_floppy" }
 
         cdl_option CYGHWR_MEMORY_LAYOUT_LDI {
             display "Memory layout linker script fragment"
             flavor data
             no_define
             define -file system.h CYGHWR_MEMORY_LAYOUT_LDI
-            calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_i386_pc_ram.ldi>" : \
-		         CYG_HAL_STARTUP == "ROM" ? "<pkgconf/mlt_i386_pc_rom.ldi>" : \
-                                                    "<pkgconf/mlt_i386_pc_floppy.ldi>" }
+            calculated { CYG_HAL_STARTUP == "RAM"  ? "<pkgconf/mlt_i386_pc_ram.ldi>" : \
+		         CYG_HAL_STARTUP == "ROM"  ? "<pkgconf/mlt_i386_pc_rom.ldi>" : \
+		         CYG_HAL_STARTUP == "GRUB" ? "<pkgconf/mlt_i386_pc_grub.ldi>" : \
+                                                     "<pkgconf/mlt_i386_pc_floppy.ldi>" }
         }
 
         cdl_option CYGHWR_MEMORY_LAYOUT_H {
@@ -276,9 +291,10 @@ cdl_package CYGPKG_HAL_I386_PC {
             flavor data
             no_define
             define -file system.h CYGHWR_MEMORY_LAYOUT_H
-            calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_i386_pc_ram.h>" : \
-		         CYG_HAL_STARTUP == "ROM" ? "<pkgconf/mlt_i386_pc_rom.h>" : \
-                                                    "<pkgconf/mlt_i386_pc_floppy.h>" }
+            calculated { CYG_HAL_STARTUP == "RAM"  ? "<pkgconf/mlt_i386_pc_ram.h>" : \
+		         CYG_HAL_STARTUP == "ROM"  ? "<pkgconf/mlt_i386_pc_rom.h>" : \
+		         CYG_HAL_STARTUP == "GRUB" ? "<pkgconf/mlt_i386_pc_grub.h>" : \
+                                                     "<pkgconf/mlt_i386_pc_floppy.h>" }
         }
     }
 
new file mode 100644
--- /dev/null
+++ b/packages/hal/i386/pc/current/include/pkgconf/mlt_i386_pc_grub.h
@@ -0,0 +1,22 @@
+// eCos memory layout - Fri Oct 20 08:15:20 2000
+
+// This is a generated file - do not edit
+
+#ifndef __ASSEMBLER__
+#include <cyg/infra/cyg_type.h>
+#include <stddef.h>
+
+#endif
+#define CYGMEM_REGION_ram (0x00100000)
+#define CYGMEM_REGION_ram_SIZE (0x01000000)
+#define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
+#ifndef __ASSEMBLER__
+extern char CYG_LABEL_NAME (__heap1) [];
+#endif
+#define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1))
+#define CYGMEM_SECTION_heap1_SIZE (0x01000000 - (size_t) CYG_LABEL_NAME (__heap1))
+#ifndef __ASSEMBLER__
+extern char CYG_LABEL_NAME (__pci_window) [];
+#endif
+#define CYGMEM_SECTION_pci_window (CYG_LABEL_NAME (__pci_window))
+#define CYGMEM_SECTION_pci_window_SIZE (0x64000)
new file mode 100644
--- /dev/null
+++ b/packages/hal/i386/pc/current/include/pkgconf/mlt_i386_pc_grub.ldi
@@ -0,0 +1,29 @@
+// eCos memory layout - Fri Oct 20 08:15:20 2000
+
+// This is a generated file - do not edit
+
+#include <cyg/infra/cyg_type.inc>
+
+MEMORY
+{
+    ram : ORIGIN = 0x0, LENGTH = 0x1000000
+}
+
+SECTIONS
+{
+    SECTIONS_BEGIN
+    SECTION_vectors (ram, 0x108000, LMA_EQ_VMA)
+    SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA)
+    SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA)
+    SECTION_rodata1 (ram, ALIGN (0x8), LMA_EQ_VMA)
+    SECTION_rodata (ram, ALIGN (0x8), LMA_EQ_VMA)
+    SECTION_fixup (ram, ALIGN (0x4), LMA_EQ_VMA)
+    SECTION_gcc_except_table (ram, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_rel__got (ram, ALIGN (0x1), LMA_EQ_VMA)
+    SECTION_data (ram, ALIGN (0x8), LMA_EQ_VMA)
+    SECTION_sbss (ram, ALIGN (0x4), LMA_EQ_VMA)
+    SECTION_bss (ram, ALIGN (0x10), LMA_EQ_VMA)
+    CYG_LABEL_DEFN(__pci_window) = ALIGN(0x10); . = CYG_LABEL_DEFN(__pci_window) + 0x64000;
+    CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
+    SECTIONS_END
+}
new file mode 100644
--- /dev/null
+++ b/packages/hal/i386/pc/current/include/pkgconf/mlt_i386_pc_grub.mlt
@@ -0,0 +1,15 @@
+version 0
+region ram 0 1000000 0 !
+section vectors 0 1 0 1 1 1 1 1 108000 10000 text text !
+section text 0 4 0 1 0 1 0 1 fini fini !
+section fini 0 4 0 1 0 1 0 1 rodata1 rodata1 !
+section rodata1 0 8 0 1 0 1 0 1 rodata rodata !
+section rodata 0 8 0 1 0 1 0 1 fixup fixup !
+section fixup 0 4 0 1 0 1 0 1 gcc_except_table gcc_except_table !
+section gcc_except_table 0 1 0 1 0 1 0 1 rel.got rel.got !
+section rel.got 0 1 0 1 0 1 0 1 data data !
+section data 0 8 0 1 0 1 0 1 sbss sbss !
+section sbss 0 4 0 1 0 1 0 1 bss bss !
+section bss 0 10 0 1 0 1 0 1 pci_window pci_window !
+section pci_window 64000 10 0 0 0 1 0 1 heap1 heap1 !
+section heap1 0 8 0 0 0 0 0 0 !
--- a/packages/hal/i386/pc/current/include/platform.inc
+++ b/packages/hal/i386/pc/current/include/platform.inc
@@ -66,9 +66,15 @@
 #define CYGPKG_HAL_I386_CPU_INIT_DEFINED
 
 ##=============================================================================
-## ROM startup
+## ROM and GRUB startup
+##
+## Although these two startup types are, on the face of it, very different,
+## the actual work that needs to be done here for them both is much the same.
+## In both cases the system has been initialized in real mode and the transition 
+## to 32 bit protected mode has been done. Here all we need to do is set up
+## our own GDT and IDT, reload the segment registers and proceed.
 
-#ifdef CYG_HAL_STARTUP_ROM
+#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_GRUB)
 
 	.macro	hal_cpu_init
 
@@ -141,6 +147,19 @@ gdtStart:
 	.align	4, 0xFF
 gdtEnd:
 
+#if defined(CYG_HAL_STARTUP_GRUB)
+        # Multiboot header -- this must be in the first 8k 
+        # of the image file.
+
+#define GRUB_MAGIC      0x1BADB002      /* Magic number */
+#define GRUB_FLAGS      0x00000000      /* Flags        */
+        
+        .align	4, 0xFF        
+        .long   GRUB_MAGIC
+        .long   GRUB_FLAGS
+        .long   0-GRUB_MAGIC-GRUB_FLAGS /* Checksum */
+#endif
+
 3:
 	# Set up data selectors
 	movw	$0x10, %ax
@@ -150,14 +169,25 @@ 3:
 	movw	%ax, %gs
 
 	movw	%ax, %ss
-	
-	# Set up SP
+        
+        # Set up SP
 	movl	$__interrupt_stack,%esp
 	
 	/* Reset the flags register. */
 	push	$0
 	popf
 
+#if defined(CYG_HAL_STARTUP_GRUB)
+        # Save the multiboot info passed in %EBX away into a
+	# global variable for later use.
+        .data
+        .global hal_multiboot_info
+hal_multiboot_info:     
+        .long   0
+        .text
+        movl    %ebx,hal_multiboot_info
+#endif       
+        
 hal_cpu_init_end:
         nop
 
new file mode 100644
--- /dev/null
+++ b/packages/hal/i386/pc/current/misc/menu.lst
@@ -0,0 +1,38 @@
+# Example GRUB boot menu configuration file for eCos
+
+default 0
+timeout 30
+
+# eCos tm_basic test from dd0
+title eCos - tm_basic fd0
+root (fd0)
+kernel /boot/tm_basic
+
+# eCos tm_basic test from hd0
+title eCos - tm_basic hd0
+root (hd0,0)
+kernel /boot/tm_basic
+
+# eCos tcp_echo test from fd0
+title eCos - tcp_echo fd0
+root (fd0)
+kernel /boot/tcp_echo
+
+# eCos tcp_echo test from hd0
+title eCos - tcp_echo hd0
+root (hd0)
+kernel /boot/tcp_echo
+
+# eCos nc_test_slave test from fd0
+title eCos - nc_test_slave fd0
+root (fd0)
+kernel /boot/nc_test_slave
+
+# eCos nc_test_slave test from hd0
+title eCos - nc_test_slave hd0
+root (hd0)
+kernel /boot/nc_test_slave
+
+#end
+
+
--- a/packages/hal/i386/pc/current/src/plf_misc.c
+++ b/packages/hal/i386/pc/current/src/plf_misc.c
@@ -135,18 +135,17 @@ void hal_platform_init(void)
          vector <= CYGNUM_HAL_EXCEPTION_MAX;
          vector++)        
     {
-        HAL_VSR_SET( vector, &__default_exception_vsr, NULL );
+#if defined(CYGHWR_HAL_I386_FPU_SWITCH_LAZY)
+        // If we are doing lazy FPU switching, the FPU switch VSR has
+        // already been installed, so avoid overwriting it.
+        if( vector != CYGNUM_HAL_VECTOR_NO_DEVICE )
+#endif
+        {
+            HAL_VSR_SET( vector, &__default_exception_vsr, NULL );
+        }
     }
 #endif
-    
-#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT)    
-    {
-        void hal_ctrlc_isr_init(void);
-        hal_ctrlc_isr_init();
-    }
 
-#endif
-        
 #ifdef CYGPKG_REDBOOT
 
     // Start the timer device running if we are in a RedBoot
@@ -158,6 +157,15 @@ void hal_platform_init(void)
     
     hal_if_init();
 
+#if defined(CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT) || \
+    defined(CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT)
+    {
+        void hal_ctrlc_isr_init(void);
+        hal_ctrlc_isr_init();
+    }
+
+#endif
+        
 #ifdef CYGPKG_HAL_SMP_SUPPORT
 
     cyg_hal_smp_init();
--- a/packages/hal/i386/pc/current/src/plf_stub.c
+++ b/packages/hal/i386/pc/current/src/plf_stub.c
@@ -81,10 +81,6 @@ externC char idtStart[];
 
 void hal_pc_stubs_init(void)
 {
-    int i ;
-    for(i=0; i<=31; i++)
-        HAL_VSR_SET(i,&__default_exception_vsr,NULL);	
-
 #if defined(CYGSEM_REDBOOT_BSP_SYSCALLS)
     cyg_hal_pc_set_idt_entry((CYG_ADDRESS)__syscall_tramp, (short *)(idtStart + (0x80 * 8)));
 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS