[syslinux:firmware] Create derivative-specific files

syslinux-bot for Matt Fleming matt.fleming at intel.com
Fri Nov 9 09:06:26 PST 2012


Commit-ID:  9415cfeb0a3d641eea9c6b877278e1acbc4ee830
Gitweb:     http://www.syslinux.org/commit/9415cfeb0a3d641eea9c6b877278e1acbc4ee830
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Fri, 31 Aug 2012 17:10:14 -0700
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Tue, 4 Sep 2012 18:49:38 +0100

Create derivative-specific files

Instead of having derivative-specific code within the assembly files
and guarded by %if SYSLINUX, etc move all the code to C files so that
the correct get_derivative_info() function can be wired up at runtime.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/lib/syslinux/dsinfo.c |    9 +-------
 core/Makefile               |   14 +++++++-----
 core/comboot.inc            |   48 +------------------------------------------
 core/diskboot.inc           |    2 +-
 core/fs/pxe/dhcp_option.c   |    2 +-
 core/fs/pxe/pxe.h           |   14 +----------
 core/include/fs.h           |    2 +
 core/isolinux-c.c           |   22 +++++++++++++++++++
 core/isolinux.asm           |    6 +++++
 core/ldlinux-c.c            |   19 +++++++++++++++++
 core/pxelinux-c.c           |   22 +++++++++++++++++++
 core/pxelinux.asm           |   17 +--------------
 efi/Makefile                |    3 +-
 efi/derivative.c            |   20 +++++++++++++++++
 efi/main.c                  |    9 --------
 15 files changed, 108 insertions(+), 101 deletions(-)

diff --git a/com32/lib/syslinux/dsinfo.c b/com32/lib/syslinux/dsinfo.c
index c1f02a5..f7126bf 100644
--- a/com32/lib/syslinux/dsinfo.c
+++ b/com32/lib/syslinux/dsinfo.c
@@ -34,12 +34,5 @@ union syslinux_derivative_info __syslinux_derivative_info;
 
 void __constructor __syslinux_get_derivative_info(void)
 {
-    com32sys_t *const r = &__syslinux_derivative_info.rr.r;
-
-    r->eax.w[0] = 0x000A;
-    __intcall(0x22, r, r);
-
-    __syslinux_derivative_info.r.esbx = MK_PTR(r->es, r->ebx.w[0]);
-    __syslinux_derivative_info.r.fssi = MK_PTR(r->fs, r->esi.w[0]);
-    __syslinux_derivative_info.r.gsdi = MK_PTR(r->gs, r->edi.w[0]);
+    get_derivative_info(&__syslinux_derivative_info);
 }
diff --git a/core/Makefile b/core/Makefile
index 3a1e875..1f68da6 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -49,8 +49,8 @@ ALLSRC    = $(NASMSRC) $(NASMHDR) $(CSRC) $(SSRC) $(CHDR) $(OTHERSRC)
 COBJ	 := $(patsubst %.c,%.o,$(CSRC))
 SOBJ	 := $(patsubst %.S,%.o,$(SSRC))
 
-# Don't include console objects
-COBJS	 = $(filter-out rawcon.o plaincon.o,$(COBJ))
+# Don't include derivative-specific objects
+COBJS	 = $(filter-out rawcon.o plaincon.o pxelinux-c.o ldlinux-c.o isolinux-c.o,$(COBJ))
 
 LIB	 = libcom32.a
 LIBS	 = $(LIB) --whole-archive $(com32)/lib/libcom32core.a
@@ -118,7 +118,7 @@ AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a libpxelinux.a
 	$(OBJDUMP) -h $@ > $(@:.elf=.sec)
 	$(PERL) lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
 
-libisolinux.a: rawcon.o
+libisolinux.a: rawcon.o isolinux-c.o
 	rm -f $@
 	$(AR) cq $@ $^
 	$(RANLIB) $@
@@ -126,10 +126,12 @@ libisolinux.a: rawcon.o
 libisolinux-debug.a: libisolinux.a
 	cp $^ $@
 
-libpxelinux.a: libisolinux.a
-	cp $^ $@
+libpxelinux.a: rawcon.o pxelinux-c.o
+	rm -f $@
+	$(AR) cq $@ $^
+	$(RANLIB) $@
 
-libldlinux.a: plaincon.o
+libldlinux.a: plaincon.o ldlinux-c.o
 	rm -f $@
 	$(AR) cq $@ $^
 	$(RANLIB) $@
diff --git a/core/comboot.inc b/core/comboot.inc
index 175c50c..62c79ec 100644
--- a/core/comboot.inc
+++ b/core/comboot.inc
@@ -486,52 +486,6 @@ comapi_pxecall	equ comapi_err			; Not available
 %endif
 
 ;
-; INT 22h AX=000Ah	Get Derivative-Specific Info
-;
-comapi_derinfo:
-		mov P_AL,my_id
-%if IS_PXELINUX
-		mov ax,[APIVer]
-		mov P_DX,ax
-		mov ax,[StrucPtr]
-		mov P_BX,ax
-		mov ax,[StrucPtr+2]
-		mov P_ES,ax
-		mov ax,[InitStack]
-		mov P_SI,ax
-		mov ax,[InitStack+2]
-		mov P_FS,ax
-		mov eax,[IPInfo.MyIP]
-		mov P_ECX,eax
-		mov P_GS,0
-		mov P_DI,IPInfo
-%else
-		; Physical medium...
-
-		mov al,[SectorShift]
-		mov P_CL,al
-		mov al,[DriveNumber]
-		mov P_DL,al
-		mov P_FS,cs
-		mov P_SI,OrigESDI
-		mov P_GS,cs
-		mov P_DI,Hidden
-%if IS_SYSLINUX || IS_EXTLINUX
-		mov P_ES,cs
-		mov P_BX,PartInfo
-%elif IS_ISOLINUX
-		mov P_ES,cs
-		mov P_BX,spec_packet
-		mov ax,[BIOSType]
-		sub ax,bios_cdrom
-		shr ax,2
-		mov P_CH,al		; Mode (el torito/cbios/ebios)
-%endif
-%endif
-		clc
-		ret
-
-;
 ; INT 22h AX=000Bh	Get Serial Console Configuration
 ;
 comapi_serialcfg:
@@ -801,7 +755,7 @@ int22_table:
 		dw comapi_read		; 0007 read file
 		dw comapi_close		; 0008 close file
 		dw comapi_pxecall	; 0009 call PXE stack
-		dw comapi_derinfo	; 000A derivative-specific info
+		dw comapi_err		; 000A derivative-specific info
 		dw comapi_serialcfg	; 000B get serial port config
 		dw comapi_cleanup	; 000C perform final cleanup
 		dw comapi_err		; 000D clean up then bootstrap
diff --git a/core/diskboot.inc b/core/diskboot.inc
index 3e42044..be81626 100644
--- a/core/diskboot.inc
+++ b/core/diskboot.inc
@@ -28,7 +28,7 @@
 ; reduce the code size...
 ;
 
-		global StackBuf
+		global StackBuf, PartInfo, Hidden, OrigESDI, DriveNumber
 StackBuf	equ STACK_TOP-44-92	; Start the stack here (grow down - 4K)
 PartInfo	equ StackBuf
 .mbr		equ PartInfo
diff --git a/core/fs/pxe/dhcp_option.c b/core/fs/pxe/dhcp_option.c
index f63d4a9..f2a9612 100644
--- a/core/fs/pxe/dhcp_option.c
+++ b/core/fs/pxe/dhcp_option.c
@@ -233,7 +233,7 @@ void parse_dhcp(const void *pkt, size_t pkt_len)
     const struct bootp_t *dhcp = (const struct bootp_t *)pkt;
     int opt_len;
 
-    IPInfo.ipv4 = 4;		/* This is IPv4 only for now... */
+    IPInfo.ipver = 4;		/* This is IPv4 only for now... */
 
     over_load = 0;
     if (ip_ok(dhcp->yip))
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index c754106..99a2cf2 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -21,6 +21,7 @@
 #define PXE_H
 
 #include <syslinux/pxe_api.h>
+#include <syslinux/config.h>
 #include "fs.h"			/* For MAX_OPEN, should go away */
 
 /*
@@ -169,20 +170,9 @@ struct pxe_pvt_inode {
 #define PVT(i) ((struct pxe_pvt_inode *)((i)->pvt))
 
 /*
- * Network boot information
- */
-struct ip_info {
-    uint32_t ipv4;
-    uint32_t myip;
-    uint32_t serverip;
-    uint32_t gateway;
-    uint32_t netmask;
-};
-
-/*
  * Variable externs
  */
-extern struct ip_info IPInfo;
+extern struct syslinux_ipinfo IPInfo;
 
 extern uint8_t MAC[];
 extern char BOOTIFStr[];
diff --git a/core/include/fs.h b/core/include/fs.h
index 673be38..c648d2a 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -199,6 +199,8 @@ void close_file(uint16_t handle);
 void pm_close_file(com32sys_t *);
 int open_config(void);
 
+extern uint16_t SectorShift;
+
 /* chdir.c */
 void pm_realpath(com32sys_t *regs);
 size_t realpath(char *dst, const char *src, size_t bufsize);
diff --git a/core/isolinux-c.c b/core/isolinux-c.c
new file mode 100644
index 0000000..bdc7df5
--- /dev/null
+++ b/core/isolinux-c.c
@@ -0,0 +1,22 @@
+#include <syslinux/config.h>
+#include <com32.h>
+#include <fs.h>
+
+extern far_ptr_t OrigESDI;
+extern uint64_t Hidden;
+extern uint16_t BIOSType;
+extern uint16_t bios_cdrom;
+extern uint8_t DriveNumber;
+extern uint8_t spec_packet;
+
+void get_derivative_info(union syslinux_derivative_info *di)
+{
+	di->iso.filesystem = SYSLINUX_FS_ISOLINUX;
+	di->iso.sector_shift = SectorShift;
+	di->iso.drive_number = DriveNumber;
+	di->iso.cd_mode = (BIOSType - bios_cdrom >> 2);
+
+	di->iso.spec_packet = spec_packet;
+	di->iso.esdi_ptr = GET_PTR(OrigESDI);
+	di->iso.partoffset = Hidden;
+}
diff --git a/core/isolinux.asm b/core/isolinux.asm
index 06291f8..39e5e5c 100644
--- a/core/isolinux.asm
+++ b/core/isolinux.asm
@@ -78,13 +78,16 @@ ImageSectors	resw 1			; isolinux.bin size, sectors
 GetlinsecPtr	resw 1			; The sector-read pointer
 BIOSName	resw 1			; Display string for BIOS type
 %define HAVE_BIOSNAME 1
+		global BIOSType
 BIOSType	resw 1
 DiskError	resb 1			; Error code for disk I/O
+		global DriveNumber
 DriveNumber	resb 1			; CD-ROM BIOS drive number
 ISOFlags	resb 1			; Flags for ISO directory search
 RetryCount      resb 1			; Used for disk access retries
 
 		alignb 8
+		global Hidden
 Hidden		resq 1			; Used in hybrid mode
 bsSecPerTrack	resw 1			; Used in hybrid mode
 bsHeads		resw 1			; Used in hybrid mode
@@ -96,6 +99,7 @@ bsHeads		resw 1			; Used in hybrid mode
 
 		alignb 8
 _spec_start	equ $
+		global spec_packet
 spec_packet:	resb 1				; Size of packet
 sp_media:	resb 1				; Media type
 sp_drive:	resb 1				; Drive number
@@ -171,6 +175,7 @@ _spec_len	equ _spec_end - _spec_start
 StackBuf	equ STACK_TOP-44	; 44 bytes needed for
 					; the bootsector chainloading
 					; code!
+		global OrigESDI
 OrigESDI	equ StackBuf-4          ; The high dword on the stack
 StackHome	equ OrigESDI
 
@@ -1092,6 +1097,7 @@ bios_ebios_str	db 'EHDD' ,0
 %endif
 
 		alignz 4
+		global bios_cdrom
 bios_cdrom:	dw getlinsec_cdrom, bios_cdrom_str
 %ifndef DEBUG_MESSAGES
 bios_cbios:	dw getlinsec_cbios, bios_cbios_str
diff --git a/core/ldlinux-c.c b/core/ldlinux-c.c
new file mode 100644
index 0000000..3d15cef
--- /dev/null
+++ b/core/ldlinux-c.c
@@ -0,0 +1,19 @@
+#include <syslinux/config.h>
+#include <com32.h>
+#include <fs.h>
+
+extern uint8_t DriveNumber;
+extern far_ptr_t PartInfo;
+extern far_ptr_t OrigESDI;
+extern uint64_t Hidden;
+
+void get_derivative_info(union syslinux_derivative_info *di)
+{
+	di->disk.filesystem = SYSLINUX_FS_SYSLINUX;
+	di->disk.sector_shift = SectorShift;
+	di->disk.drive_number = DriveNumber;
+
+	di->disk.ptab_ptr = GET_PTR(PartInfo);
+	di->disk.esdi_ptr = GET_PTR(OrigESDI);
+	di->disk.partoffset = Hidden;
+}
diff --git a/core/pxelinux-c.c b/core/pxelinux-c.c
new file mode 100644
index 0000000..a0f0bc8
--- /dev/null
+++ b/core/pxelinux-c.c
@@ -0,0 +1,22 @@
+#include <syslinux/config.h>
+#include <com32.h>
+
+extern far_ptr_t StrucPtr;
+extern far_ptr_t InitStack;
+
+/*
+ * IP information.  Note that the field are in the same order as the
+ * Linux kernel expects in the ip= option.
+ */
+struct syslinux_ipinfo IPInfo;
+uint16_t APIVer;		/* PXE API version found */
+
+void get_derivative_info(union syslinux_derivative_info *di)
+{
+	di->pxe.filesystem = SYSLINUX_FS_PXELINUX;
+	di->pxe.apiver = APIVer;
+	di->pxe.pxenvptr = GET_PTR(StrucPtr);
+	di->pxe.stack = GET_PTR(InitStack);
+	di->pxe.ipinfo = &IPInfo;
+	di->pxe.myip = IPInfo.myip;
+}
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index aa11702..5735e64 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -81,10 +81,9 @@ InitStack	resd 1
 PXEStack	resd 1			; Saved stack during PXE call
 
 		alignb 4
-                global DHCPMagic, RebootTime, APIVer
+                global DHCPMagic, RebootTime, StrucPtr
 RebootTime	resd 1			; Reboot timeout, if set by option
 StrucPtr	resw 2			; Pointer to PXENV+ or !PXE structure
-APIVer		resw 1			; PXE API version found
 LocalBootType	resw 1			; Local boot return code
 DHCPMagic	resb 1			; PXELINUX magic flags
 
@@ -571,17 +570,3 @@ syslinux_banner	db CR, LF, MY_NAME, ' ', VERSION_STR, ' ', DATE_STR, ' ', 0
 		section .data16
                 global KeepPXE
 KeepPXE		db 0			; Should PXE be kept around?
-
-;
-; IP information.  Note that the field are in the same order as the
-; Linux kernel expects in the ip= option.
-;
-		section .bss16
-		alignb 4
-		global IPInfo
-IPInfo:
-.IPv4		resd 1			; IPv4 information
-.MyIP		resd 1			; My IP address 
-.ServerIP	resd 1
-.GatewayIP	resd 1
-.Netmask	resd 1
diff --git a/efi/Makefile b/efi/Makefile
index 3304d76..19c1a4d 100644
--- a/efi/Makefile
+++ b/efi/Makefile
@@ -21,7 +21,8 @@ CORE_COBJ := $(patsubst %.c,%.o,$(CORE_CSRC))
 # Don't include console objects
 CORE_OBJS = $(filter-out $(core)/hello.o $(core)/rawcon.o \
 	$(core)/plaincon.o $(core)/strcasecmp.o $(core)/bios.o \
-	$(core)/fs/diskio_bios.o,$(CORE_COBJ))
+	$(core)/fs/diskio_bios.o $(core)/ldlinux-c.o $(core)/isolinux-c.o \
+	$(core)/pxelinux-c.o,$(CORE_COBJ))
 LIB_OBJS = $(addprefix $(com32)/lib/,$(CORELIBOBJS))
 
 CSRC = $(wildcard *.c)
diff --git a/efi/derivative.c b/efi/derivative.c
new file mode 100644
index 0000000..aa72fb1
--- /dev/null
+++ b/efi/derivative.c
@@ -0,0 +1,20 @@
+/*
+ * We don't have separate boot loader derivatives under EFI, rather,
+ * the derivative info reflects the capabilities of the machine. For
+ * instance, if we have the PXE Base Code Protocol, then we support
+ * PXELINUX, if we have the Disk I/O Protocol, we support SYSLINUX,
+ * etc.
+ */
+#include <syslinux/config.h>
+
+/*
+ * IP information.  Note that the field are in the same order as the
+ * Linux kernel expects in the ip= option.
+ */
+struct syslinux_ipinfo IPInfo;
+uint16_t APIVer;		/* PXE API version found */
+
+void get_derivative_info(union syslinux_derivative_info *di)
+{
+	di->disk.filesystem = SYSLINUX_FS_SYSLINUX;
+}
diff --git a/efi/main.c b/efi/main.c
index 7c1887c..5241292 100644
--- a/efi/main.c
+++ b/efi/main.c
@@ -66,14 +66,6 @@ struct iso_boot_info {
 	uint32_t reserved[10];      /* Currently unused */
 } iso_boot_info;
 
-struct ip_info {
-	uint32_t ipv4;
-	uint32_t myip;
-	uint32_t serverip;
-	uint32_t gateway;
-	uint32_t netmask;
-} IPInfo;
-
 uint8_t DHCPMagic;
 uint32_t RebootTime;
 
@@ -86,7 +78,6 @@ const uint16_t IPAppends[32];
 uint16_t BIOS_fbm = 1;
 far_ptr_t InitStack;
 char StackBuf[4096];
-uint16_t APIVer;
 far_ptr_t PXEEntry;
 unsigned int __bcopyxx_len = 0;
 


More information about the Syslinux-commits mailing list