summaryrefslogtreecommitdiff
path: root/gpxe/src/arch/i386/transitions
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-02-17 20:17:17 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-02-17 20:17:17 -0800
commitd0c6656a62113b913948361779d6298fe76f6e61 (patch)
treeefa2541a1abae4760717c6db421ea818114ab6f7 /gpxe/src/arch/i386/transitions
parent85b92a462dab7ce36c48614ea18314f8fc83ca9c (diff)
downloadsyslinux-d0c6656a62113b913948361779d6298fe76f6e61.tar.gz
Update gPXE to version 0.9.6+ 277b84c6e7d49f3cf01c855007f591de8c7cb75f
Update gPXE to version 0.9.6+, from commit 277b84c6e7d49f3cf01c855007f591de8c7cb75f in the main gPXE repository. The only differences is src/config/general.h which has a few protocols added, and src/arch/i386/prefix/boot1a.S which was called boot1a.s in the upstream repository.
Diffstat (limited to 'gpxe/src/arch/i386/transitions')
-rwxr-xr-x[-rw-r--r--]gpxe/src/arch/i386/transitions/librm.S53
-rwxr-xr-x[-rw-r--r--]gpxe/src/arch/i386/transitions/librm_mgmt.c101
2 files changed, 81 insertions, 73 deletions
diff --git a/gpxe/src/arch/i386/transitions/librm.S b/gpxe/src/arch/i386/transitions/librm.S
index ff4b1d97..8cf1f7f5 100644..100755
--- a/gpxe/src/arch/i386/transitions/librm.S
+++ b/gpxe/src/arch/i386/transitions/librm.S
@@ -19,9 +19,6 @@
#define SIZEOF_I386_ALL_REGS ( SIZEOF_REAL_MODE_REGS + SIZEOF_I386_FLAGS )
.arch i386
- .section ".text16", "ax", @progbits
- .section ".text16.data", "aw", @progbits
- .section ".data16", "aw", @progbits
/****************************************************************************
* Global descriptor table
@@ -47,7 +44,7 @@
#else
#define RM_LIMIT_16_19__AVL__SIZE__GRANULARITY 0x00
#endif
- .section ".data16"
+ .section ".data16", "aw", @progbits
.align 16
gdt:
gdtr: /* The first GDT entry is unused, the GDTR can fit here. */
@@ -99,7 +96,7 @@ gdt_end:
* %edi : Physical base of protected-mode code (virt_offset)
****************************************************************************
*/
- .section ".text16"
+ .section ".text16", "ax", @progbits
.code16
.globl init_librm
init_librm:
@@ -149,7 +146,7 @@ init_librm:
popl %eax
lret
- .section ".text16"
+ .section ".text16", "ax", @progbits
.code16
.weak idt_init
set_seg_base:
@@ -177,7 +174,7 @@ idt_init: /* Reuse the return opcode here */
*
****************************************************************************
*/
- .section ".text16"
+ .section ".text16", "ax", @progbits
.code16
real_to_prot:
/* Make sure we have our data segment available */
@@ -203,13 +200,13 @@ real_to_prot:
/* Switch to protected mode */
cli
- data32 lgdt gdtr
- data32 lidt idtr
+ data32 lgdt gdtr
+ data32 lidt idtr
movl %cr0, %eax
orb $CR0_PE, %al
movl %eax, %cr0
data32 ljmp $VIRTUAL_CS, $1f
- .section ".text"
+ .section ".text", "ax", @progbits
.code32
1:
/* Set up protected-mode data segments and stack pointer */
@@ -240,7 +237,7 @@ real_to_prot:
ret
/* Default IDTR with no interrupts */
- .section ".data16"
+ .section ".data16", "aw", @progbits
.weak idtr
idtr:
rm_idtr:
@@ -266,7 +263,7 @@ rm_idtr:
*
****************************************************************************
*/
- .section ".text"
+ .section ".text", "ax", @progbits
.code32
prot_to_real:
/* Add return address to data to be moved to RM stack */
@@ -296,7 +293,7 @@ prot_to_real:
movw %ax, %gs
movw %ax, %ss
ljmp $REAL_CS, $1f
- .section ".text16"
+ .section ".text16", "ax", @progbits
.code16
1:
/* Switch to real mode */
@@ -316,7 +313,7 @@ p2r_jump_target:
movl %edx, %esp
/* Reset IDTR to the real-mode defaults */
- lidt rm_idtr
+ data32 lidt rm_idtr
/* Return to real-mode address */
data32 ret
@@ -328,13 +325,13 @@ p2r_jump_target:
* rather than .data16 because code needs to be able to locate
* the data segment.
*/
- .section ".data16"
+ .section ".data16", "aw", @progbits
p2r_jump_vector:
.word p2r_jump_target
.globl rm_cs
rm_cs: .word 0
.globl rm_ds
- .section ".text16.data"
+ .section ".text16.data", "aw", @progbits
rm_ds: .word 0
/****************************************************************************
@@ -378,7 +375,7 @@ rm_ds: .word 0
#define PC_OFFSET_FUNCTION ( PC_OFFSET_RETADDR + 4 )
#define PC_OFFSET_END ( PC_OFFSET_FUNCTION + 4 )
- .section ".text16"
+ .section ".text16", "ax", @progbits
.code16
.globl prot_call
prot_call:
@@ -403,7 +400,7 @@ prot_call:
movl $PC_OFFSET_END, %ecx
pushl $1f
jmp real_to_prot
- .section ".text"
+ .section ".text", "ax", @progbits
.code32
1:
/* Set up environment expected by C code */
@@ -419,13 +416,13 @@ prot_call:
movl $PC_OFFSET_END, %ecx
pushl $1f
jmp prot_to_real
- .section ".text16"
+ .section ".text16", "ax", @progbits
.code16
1:
/* Reload GDT and IDT, restore registers and flags and return */
movw %sp, %bp
- lgdt (%bp)
- lidt 8(%bp)
+ data32 lgdt (%bp)
+ data32 lidt 8(%bp)
addw $20, %sp /* also skip %cs and %ss */
popw %ds
popw %es
@@ -475,7 +472,7 @@ prot_call:
#define RC_OFFSET_FUNCTION ( RC_OFFSET_RETADDR + 4 )
#define RC_OFFSET_END ( RC_OFFSET_FUNCTION + 4 )
- .section ".text"
+ .section ".text", "ax", @progbits
.code32
.globl real_call
real_call:
@@ -487,7 +484,7 @@ real_call:
movl $( RC_OFFSET_RETADDR + 4 /* function pointer copy */ ), %ecx
pushl $1f
jmp prot_to_real
- .section ".text16"
+ .section ".text16", "ax", @progbits
.code16
1:
/* Call real-mode function */
@@ -503,7 +500,7 @@ real_call:
movl $RC_OFFSET_RETADDR, %ecx
pushl $1f
jmp real_to_prot
- .section ".text"
+ .section ".text", "ax", @progbits
.code32
1:
/* Restore registers and return */
@@ -514,7 +511,7 @@ real_call:
/* Function vector, used because "call xx(%sp)" is not a valid
* 16-bit expression.
*/
- .section ".data16"
+ .section ".data16", "aw", @progbits
rc_function: .word 0, 0
/****************************************************************************
@@ -551,7 +548,7 @@ rc_function: .word 0, 0
* to us.
****************************************************************************
*/
- .section ".data"
+ .section ".data", "aw", @progbits
.globl rm_sp
rm_sp: .word 0
.globl rm_ss
@@ -567,13 +564,13 @@ pm_esp: .long _estack
****************************************************************************
*/
/* Internal copies, created by init_librm (which runs in real mode) */
- .section ".data16"
+ .section ".data16", "aw", @progbits
_virt_offset: .long 0
_text16: .long 0
_data16: .long 0
/* Externally-visible copies, created by real_to_prot */
- .section ".data"
+ .section ".data", "aw", @progbits
.globl virt_offset
virt_offset: .long 0
.globl text16
diff --git a/gpxe/src/arch/i386/transitions/librm_mgmt.c b/gpxe/src/arch/i386/transitions/librm_mgmt.c
index 59b2eabc..50569f8e 100644..100755
--- a/gpxe/src/arch/i386/transitions/librm_mgmt.c
+++ b/gpxe/src/arch/i386/transitions/librm_mgmt.c
@@ -1,45 +1,56 @@
-/*
- * librm: a library for interfacing to real-mode code
- *
- * Michael Brown <mbrown@fensystems.co.uk>
- *
- */
-
-#include <stdint.h>
-#include <librm.h>
-
-/*
- * This file provides functions for managing librm.
- *
- */
-
-/**
- * Allocate space on the real-mode stack and copy data there from a
- * user buffer
- *
- * @v data User buffer
- * @v size Size of stack data
- * @ret sp New value of real-mode stack pointer
- */
-uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) {
- userptr_t rm_stack;
- rm_sp -= size;
- rm_stack = real_to_user ( rm_ss, rm_sp );
- memcpy_user ( rm_stack, 0, data, 0, size );
- return rm_sp;
-};
-
-/**
- * Deallocate space on the real-mode stack, optionally copying back
- * data to a user buffer.
- *
- * @v data User buffer
- * @v size Size of stack data
- */
-void remove_user_from_rm_stack ( userptr_t data, size_t size ) {
- if ( data ) {
- userptr_t rm_stack = real_to_user ( rm_ss, rm_sp );
- memcpy_user ( rm_stack, 0, data, 0, size );
- }
- rm_sp += size;
-};
+/*
+ * librm: a library for interfacing to real-mode code
+ *
+ * Michael Brown <mbrown@fensystems.co.uk>
+ *
+ */
+
+#include <stdint.h>
+#include <realmode.h>
+
+/*
+ * This file provides functions for managing librm.
+ *
+ */
+
+/**
+ * Allocate space on the real-mode stack and copy data there from a
+ * user buffer
+ *
+ * @v data User buffer
+ * @v size Size of stack data
+ * @ret sp New value of real-mode stack pointer
+ */
+uint16_t copy_user_to_rm_stack ( userptr_t data, size_t size ) {
+ userptr_t rm_stack;
+ rm_sp -= size;
+ rm_stack = real_to_user ( rm_ss, rm_sp );
+ memcpy_user ( rm_stack, 0, data, 0, size );
+ return rm_sp;
+};
+
+/**
+ * Deallocate space on the real-mode stack, optionally copying back
+ * data to a user buffer.
+ *
+ * @v data User buffer
+ * @v size Size of stack data
+ */
+void remove_user_from_rm_stack ( userptr_t data, size_t size ) {
+ if ( data ) {
+ userptr_t rm_stack = real_to_user ( rm_ss, rm_sp );
+ memcpy_user ( rm_stack, 0, data, 0, size );
+ }
+ rm_sp += size;
+};
+
+PROVIDE_UACCESS_INLINE ( librm, phys_to_user );
+PROVIDE_UACCESS_INLINE ( librm, user_to_phys );
+PROVIDE_UACCESS_INLINE ( librm, virt_to_user );
+PROVIDE_UACCESS_INLINE ( librm, user_to_virt );
+PROVIDE_UACCESS_INLINE ( librm, userptr_add );
+PROVIDE_UACCESS_INLINE ( librm, memcpy_user );
+PROVIDE_UACCESS_INLINE ( librm, memmove_user );
+PROVIDE_UACCESS_INLINE ( librm, memset_user );
+PROVIDE_UACCESS_INLINE ( librm, strlen_user );
+PROVIDE_UACCESS_INLINE ( librm, memchr_user );