[syslinux:master] com32: export the filename of a com32 module to the module itself
syslinux-bot for H. Peter Anvin
hpa at linux.intel.com
Mon Mar 29 17:30:11 PDT 2010
Commit-ID: 68a7538d5a80ec8db48c02d4a9de7199df0af9f9
Gitweb: http://syslinux.zytor.com/commit/68a7538d5a80ec8db48c02d4a9de7199df0af9f9
Author: H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Mon, 29 Mar 2010 16:58:30 -0700
Committer: H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Mon, 29 Mar 2010 16:58:30 -0700
com32: export the filename of a com32 module to the module itself
Export the filename of the com32 module to the module itself, setting
argv[0].
Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>
---
com32/include/com32.h | 7 ++++---
com32/lib/sys/argv.c | 5 +++--
com32/lib/sys/entry.S | 2 +-
core/com32.inc | 14 +++++++++++++-
doc/comboot.txt | 16 ++--------------
5 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/com32/include/com32.h b/com32/include/com32.h
index aa7fb4b..665fa0b 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -95,12 +95,13 @@ typedef struct {
extern struct com32_sys_args {
uint32_t cs_sysargs;
char *cs_cmdline;
- void __cdecl(*cs_intcall) (uint8_t, const com32sys_t *, com32sys_t *);
+ void __cdecl (*cs_intcall)(uint8_t, const com32sys_t *, com32sys_t *);
void *cs_bounce;
uint32_t cs_bounce_size;
- void __cdecl(*cs_farcall) (uint32_t, const com32sys_t *, com32sys_t *);
- int __cdecl(*cs_cfarcall) (uint32_t, const void *, uint32_t);
+ void __cdecl (*cs_farcall)(uint32_t, const com32sys_t *, com32sys_t *);
+ int __cdecl (*cs_cfarcall)(uint32_t, const void *, uint32_t);
uint32_t cs_memsize;
+ const char *cs_name;
} __com32;
/*
diff --git a/com32/lib/sys/argv.c b/com32/lib/sys/argv.c
index 8e9aabd..3ff869b 100644
--- a/com32/lib/sys/argv.c
+++ b/com32/lib/sys/argv.c
@@ -37,13 +37,14 @@
#include <stddef.h>
#include <stdio.h>
#include <syslinux/align.h>
+#include <com32.h>
extern char _end[]; /* Symbol created by linker */
void *__mem_end = &_end; /* Global variable for use by malloc() */
int __parse_argv(char ***argv, const char *str)
{
- char argv0[] = "";
+ char dummy_argv0[] = "";
char *mem = __mem_end;
const char *p = str;
char *q = mem;
@@ -77,7 +78,7 @@ int __parse_argv(char ***argv, const char *str)
/* Now create argv */
arg = (char **)ALIGN_UP_FOR(q, char *);
*argv = arg;
- *arg++ = argv0; /* argv[0] */
+ *arg++ = __com32.cs_name ? __com32.cs_name : dummy_argv0; /* argv[0] */
q--; /* Point q to final null */
if (mem < q)
diff --git a/com32/lib/sys/entry.S b/com32/lib/sys/entry.S
index 53bf2ec..c34dbdf 100644
--- a/com32/lib/sys/entry.S
+++ b/com32/lib/sys/entry.S
@@ -30,7 +30,7 @@
*/
/* Number of arguments in our version of the entry structure */
-#define COM32_ARGS 7
+#define COM32_ARGS 8
.section ".init","ax"
.globl _start
diff --git a/core/com32.inc b/core/com32.inc
index 7232792..8c3f181 100644
--- a/core/com32.inc
+++ b/core/com32.inc
@@ -65,6 +65,10 @@ is_com32_image:
sub cx,si
fs rep movsb
+ mov si,KernelCName
+ mov di,Com32Name
+ call strcpy
+
call comboot_setup_api ; Set up the COMBOOT-style API
mov edi,pm_entry ; Load address
@@ -172,6 +176,7 @@ com32_call_start:
; Now everything is set up for interrupts...
+ push dword Com32Name ; Module filename
push dword [HighMemSize] ; Memory managed by Syslinux
push dword com32_cfarcall ; Cfarcall entry point
push dword com32_farcall ; Farcall entry point
@@ -179,7 +184,7 @@ com32_call_start:
push dword (xfer_buf_seg << 4) ; Bounce buffer address
push dword com32_intcall ; Intcall entry point
push dword command_line ; Command line pointer
- push dword 7 ; Argument count
+ push dword 8 ; Argument count
sti ; Interrupts OK now
call pm_entry ; Run the program...
; ... on return, fall through to com32_exit ...
@@ -425,4 +430,11 @@ RealModeEAX resd 1 ; Real mode EAX
PMESP resd 1 ; Protected-mode ESP
Com32SysSP resw 1 ; SP saved during COM32 syscall
+ section .uibss
+%if IS_SYSLINUX
+Com32Name resb FILENAME_MAX+2
+%else
+Com32Name resb FILENAME_MAX
+%endif
+
section .text
diff --git a/doc/comboot.txt b/doc/comboot.txt
index 4ef10f4..81d0602 100644
--- a/doc/comboot.txt
+++ b/doc/comboot.txt
@@ -79,7 +79,7 @@ The following arguments are passed to the program on the stack:
Address Size Meaning
[ESP] dword Return (termination) address
- [ESP+4] dword Number of additional arguments (currently 7)
+ [ESP+4] dword Number of additional arguments (currently 8)
[ESP+8] dword Pointer to the command line arguments (null-terminated string)
[ESP+12] dword Pointer to INT call helper function
[ESP+16] dword Pointer to low memory bounce buffer
@@ -87,19 +87,7 @@ The following arguments are passed to the program on the stack:
[ESP+24] dword Pointer to FAR call helper function (new in 2.05)
[ESP+28] dword Pointer to CDECL helper function (new in 3.54)
[ESP+32] dword Amount of memory controlled by the Syslinux core (new in 3.74)
-
-This corresponds to the following C prototype, available in the file
-com32/include/com32.h:
-
-/* The standard prototype for _start() */
-int _start(unsigned int __nargs,
- char *__cmdline,
- void (*__intcall)(uint8_t, com32sys_t *, com32sys_t *),
- void *__bounce_ptr,
- unsigned int __bounce_len,
- void (*__farcall)(uint32_t, com32sys_t *, com32sys_t *),
- int (*__cfarcall)(uint32_t, void *, size_t)
- );
+ [ESP+36] dword Pointer to the filename of the com32 module (new in 3.86)
The intcall helper function can be used to issue BIOS or Syslinux API
calls, and takes the interrupt number as first argument. The second
More information about the Syslinux-commits
mailing list