summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Dolezal <dolezj21@fel.cvut.cz>2014-11-20 15:00:27 +0100
committerGedare Bloom <gedare@rtems.org>2014-11-20 09:52:38 -0500
commit58af50d2e593f4a7b5e84a01ff5fbe0932989c91 (patch)
tree5df3446e74c9c7aefcfb7dbdaffd42797fadf014
parentec494ffbfc88b2085d8d4824883333b782c50b5c (diff)
downloadrtems-58af50d2e593f4a7b5e84a01ff5fbe0932989c91.tar.bz2
score: i386: functions converting real mode pointer to physical address and back
-rw-r--r--cpukit/score/cpu/i386/cpu_asm.S43
-rw-r--r--cpukit/score/cpu/i386/rtems/score/i386.h32
2 files changed, 75 insertions, 0 deletions
diff --git a/cpukit/score/cpu/i386/cpu_asm.S b/cpukit/score/cpu/i386/cpu_asm.S
index 9b395678b8..f3ef4e2c38 100644
--- a/cpukit/score/cpu/i386/cpu_asm.S
+++ b/cpukit/score/cpu/i386/cpu_asm.S
@@ -327,6 +327,49 @@ SYM (i386_Physical_to_logical):
movl ecx,eax /* eax = ecx */
ret
+/*
+ * int i386_Physical_to_real(
+ * void *address,
+ * uint16_t *segment,
+ * uint16_t *offset
+ * );
+ *
+ * Fills segment:offest realmode pointer counted from thirty-two bit physical
+ * address.
+ * Returns 0 if unconvertible, 1 if successfuly converted.
+ */
+
+.set PHYS_PTR_ARG, 4
+.set RM_PTR_SEG_ARG, 8
+.set RM_PTR_OFF_ARG, 12
+
+ PUBLIC (i386_Physical_to_real)
+
+SYM (i386_Physical_to_real):
+ movl PHYS_PTR_ARG(esp),eax
+ cmpl $0x10FFF0, eax
+ js 1f
+ movl $0, eax
+ ret
+1: cmpl $0x100000, eax
+ js 2f
+ subl $0xFFFF0, eax
+ movl RM_PTR_OFF_ARG(esp), ecx
+ movw ax, (ecx)
+ movl RM_PTR_SEG_ARG(esp), ecx
+ movw $0xFFFF, (ecx)
+ movl $1, eax
+ ret
+2: movl eax, edx
+ and $0xF, ax
+ movl RM_PTR_OFF_ARG(esp), ecx
+ movw ax, (ecx)
+ shrl $4, edx
+ movl RM_PTR_SEG_ARG(esp), ecx
+ movw dx, (ecx)
+ movl $1, eax
+ ret
+
END_CODE
END
diff --git a/cpukit/score/cpu/i386/rtems/score/i386.h b/cpukit/score/cpu/i386/rtems/score/i386.h
index 57569fc398..926627dccb 100644
--- a/cpukit/score/cpu/i386/rtems/score/i386.h
+++ b/cpukit/score/cpu/i386/rtems/score/i386.h
@@ -186,6 +186,38 @@ void *i386_Physical_to_logical(
);
/*
+ * i386_Real_to_physical
+ *
+ * Converts real mode pointer {segment, offset} to physical address.
+ */
+RTEMS_INLINE_ROUTINE void *i386_Real_to_physical(
+ uint16_t segment,
+ uint16_t offset)
+{
+ return (void *)(((uint32_t)segment<<4)+offset);
+}
+
+/*
+ * i386_Physical_to_real
+ * Retreives real mode pointer elements {segmnet, offset} from physical address
+ * Function returns the highest segment (base) address possible.
+ * Example: input address - 0x4B3A2
+ * output segment - 0x4B3A
+ * offset - 0x2
+ * input address - 0x10F12E
+ * output segment - 0xFFFF
+ * offset - 0xF13E
+ *
+ * return 0 address not convertible, must be less than 0x10FFEF
+ * 1 segment and offset extracted
+ */
+int i386_Physical_to_real(
+ void *address,
+ uint16_t *segment,
+ uint16_t *offset
+);
+
+/*
* "Simpler" names for a lot of the things defined in this file
*/