aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-06-09 22:54:51 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-06-09 22:54:51 -0700
commit79c5c65e1dcd3ab954d564876f571794768263d1 (patch)
treece88155229c1438de6849ee39fb4324e9005ca38
parentab42c9f0237af9f116433478268587e847f2eb44 (diff)
parent21e8f68b76dda9fa4dd8a70fcfe1d574cad37cc5 (diff)
downloadsyslinux-elf-79c5c65e1dcd3ab954d564876f571794768263d1.tar.gz
syslinux-elf-79c5c65e1dcd3ab954d564876f571794768263d1.tar.xz
syslinux-elf-79c5c65e1dcd3ab954d564876f571794768263d1.zip
Merge branch 'master' into core32
-rw-r--r--com32/include/com32.h29
-rw-r--r--memdisk/memdisk16.asm3
2 files changed, 21 insertions, 11 deletions
diff --git a/com32/include/com32.h b/com32/include/com32.h
index c003f7ca..aa7fb4b6 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -36,6 +36,8 @@
#define _COM32_H
#include <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
#include <klibc/compiler.h> /* For __cdecl */
/*
@@ -132,17 +134,20 @@ static inline uint16_t OFFS(const volatile void *__p)
return (uint16_t) (uintptr_t) __p & 0x000F;
}
-static inline uint16_t OFFS_WRT(const volatile void *__p, uint16_t seg)
+static inline uint16_t OFFS_WRT(const volatile void *__p, uint16_t __seg)
{
- return (uint16_t) ((uintptr_t) __p - ((uintptr_t) seg << 4));
+ return (uint16_t) ((uintptr_t) __p - ((uintptr_t) __seg << 4));
}
-static inline int OFFS_VALID(const volatile void *__p, uint16_t seg)
+#define OFFS_VALID(p,s) _OFFS_VALID((p), sizeof *(p), (s))
+
+static inline bool _OFFS_VALID(const volatile void *__p, size_t __s,
+ uint16_t __seg)
{
- uintptr_t __segstart = (uintptr_t) seg << 4;
- uintptr_t __ptr = (uintptr_t) __p;
+ uintptr_t __segstart = (uintptr_t)__seg << 4;
+ uintptr_t __offs = (uintptr_t)__p - __segstart;
- return (__ptr >= __segstart) && (__ptr <= __segstart + 0xffff);
+ return __offs <= 0x10000-__s;
}
static inline void *MK_PTR(uint16_t __seg, uint16_t __offs)
@@ -153,21 +158,27 @@ static inline void *MK_PTR(uint16_t __seg, uint16_t __offs)
/* Some tools to handle 16:16 far pointers in memory */
struct __far_ptr {
- uint32_t __ptr;
+ union {
+ uint32_t ptr;
+ struct {
+ uint16_t offs, seg;
+ };
+ };
} __attribute__ ((packed));
typedef struct __far_ptr far_ptr_t;
static inline void *GET_PTR(far_ptr_t __fptr)
{
- return MK_PTR(__fptr.__ptr >> 16, __fptr.__ptr);
+ return MK_PTR(__fptr.seg, __fptr.offs);
}
static inline far_ptr_t FAR_PTR(void *__ptr)
{
far_ptr_t __fptr;
- __fptr.__ptr = (SEG(__ptr) << 16) + OFFS(__ptr);
+ __fptr.offs = OFFS(__ptr);
+ __fptr.seg = SEG(__ptr);
return __fptr;
}
diff --git a/memdisk/memdisk16.asm b/memdisk/memdisk16.asm
index 0c5b9973..6bafae7f 100644
--- a/memdisk/memdisk16.asm
+++ b/memdisk/memdisk16.asm
@@ -159,8 +159,7 @@ copy_cmdline:
mov gs,si
lss sp,[cs:b_sssp]
movzx esp,sp
- call far [cs:b_csip]
- int 18h ; A far return -> INT 18h
+ jmp far [cs:b_csip]
;
; We enter protected mode, set up a flat 32-bit environment, run rep movsd