summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-02-23 18:14:12 -0800
committerH. Peter Anvin <hpa@zytor.com>2010-02-23 18:14:12 -0800
commit3cda063b8e079ee6518d3425650d800db4227585 (patch)
tree5c31ff2924ad2d43e0174e1c7301e950543262d4 /core
parent2e236fea2b554b7b72f66d96ceae9e3fa4da675a (diff)
downloadsyslinux-3cda063b8e079ee6518d3425650d800db4227585.tar.gz
core: add a direct 32-bit API
Add a direct 32-bit API to some functions; initially read file only. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'core')
-rw-r--r--core/com32.inc10
-rw-r--r--core/fs/fs.c21
-rw-r--r--core/include/core.h1
-rw-r--r--core/include/fs.h1
-rw-r--r--core/include/pmapi.h8
-rw-r--r--core/pmapi.c23
6 files changed, 61 insertions, 3 deletions
diff --git a/core/com32.inc b/core/com32.inc
index cb172794..810ee036 100644
--- a/core/com32.inc
+++ b/core/com32.inc
@@ -1,7 +1,7 @@
;; -----------------------------------------------------------------------
;;
;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
-;; Copyright 2009 Intel Corporation; author: H. Peter Anvin
+;; Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -17,6 +17,8 @@
;; Common code for running a COM32 image
;;
+ extern pm_api_vector
+
;
; Load a COM32 image. A COM32 image is the 32-bit analogue to a DOS
; .com file. A COM32 image is loaded at address 0x101000, with %esp
@@ -82,6 +84,7 @@ com32_start:
.pm:
; Set up the calling stack frame
+ push dword pm_api_vector
push dword [HighMemSize] ; Memory managed by Syslinux
push dword core_cfarcall ; Cfarcall entry point
push dword core_farcall ; Farcall entry point
@@ -89,7 +92,7 @@ com32_start:
push dword core_real_mode ; Bounce buffer address
push dword core_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 com32_entry ; Run the program...
; ... on return, fall through to com32_exit ...
@@ -123,7 +126,7 @@ not_com32r_msg db ': not a COM32R image', CR, LF, 0
global __com32
alignz 4
__com32:
- dd 7 ; Argument count
+ dd 8 ; Argument count
dd 0 ; No command line
dd core_intcall ; Intcall entry point
dd core_xfer_buf ; Bounce buffer address
@@ -131,3 +134,4 @@ __com32:
dd core_farcall ; Farcall entry point
dd core_cfarcall ; Cfarcall entry point
HighMemSize dd 0 ; End of memory pointer (bytes)
+ dd pm_api_vector ; Protected mode functions
diff --git a/core/fs/fs.c b/core/fs/fs.c
index d67a87ca..e0f469ba 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -137,6 +137,27 @@ void getfssec(com32sys_t *regs)
regs->ecx.l = bytes_read;
}
+size_t pmapi_read_file(uint16_t *handle, void *buf, size_t sectors)
+{
+ bool have_more;
+ size_t bytes_read;
+ struct file *file;
+
+ file = handle_to_file(*handle);
+ bytes_read = file->fs->fs_ops->getfssec(file, buf, sectors, &have_more);
+
+ /*
+ * If we reach EOF, the filesystem driver will have already closed
+ * the underlying file... this really should be cleaner.
+ */
+ if (!have_more) {
+ _close_file(file);
+ *handle = 0;
+ }
+
+ return bytes_read;
+}
+
void pm_searchdir(com32sys_t *regs)
{
char *name = MK_PTR(regs->ds, regs->edi.w[0]);
diff --git a/core/include/core.h b/core/include/core.h
index c955e730..e6364f87 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -3,6 +3,7 @@
#include <klibc/compiler.h>
#include <com32.h>
+#include <syslinux/pmapi.h>
extern char core_xfer_buf[65536];
extern char core_cache_buf[65536];
diff --git a/core/include/fs.h b/core/include/fs.h
index 8a173d9f..1f4ad280 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -187,6 +187,7 @@ void mangle_name(char *, const char *);
char *unmangle_name(char *, const char *);
int searchdir(const char *name);
void _close_file(struct file *);
+size_t pmapi_read_file(uint16_t *handle, void *buf, size_t sectors);
/* chdir.c */
void pm_realpath(com32sys_t *regs);
diff --git a/core/include/pmapi.h b/core/include/pmapi.h
new file mode 100644
index 00000000..57d2e6f7
--- /dev/null
+++ b/core/include/pmapi.h
@@ -0,0 +1,8 @@
+#ifndef PMAPI_H
+#define PMAPI_H
+
+#include <syslinux/pmapi.h>
+
+size_t pmapi_read_file(uint16_t *, void *, size_t);
+
+#endif /* PMAPI_H */
diff --git a/core/pmapi.c b/core/pmapi.c
new file mode 100644
index 00000000..f45a7fc6
--- /dev/null
+++ b/core/pmapi.c
@@ -0,0 +1,23 @@
+/* -----------------------------------------------------------------------
+ *
+ * Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
+ * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <inttypes.h>
+#include <com32.h>
+#include <syslinux/pmapi.h>
+#include "core.h"
+#include "fs.h"
+
+const struct com32_pmapi pm_api_vector =
+{
+ .read_file = pmapi_read_file,
+};