summaryrefslogtreecommitdiffstats
path: root/nuttx/arch
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-03-08 01:24:42 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-03-08 01:24:42 +0000
commit531076a259a1f8700671a3c396c91f378c39a6cc (patch)
treef6c2781c153a3ee1335aeff948f4d99f40296ef2 /nuttx/arch
parentfd0d80de07f5a3267ca2f9a33105de7400bd9b48 (diff)
misc QEMU fixes
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3351 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/arch')
-rwxr-xr-xnuttx/arch/x86/include/i486/arch.h38
-rw-r--r--nuttx/arch/x86/src/i486/i486_utils.S26
-rw-r--r--nuttx/arch/x86/src/i486/up_initialstate.c8
-rwxr-xr-xnuttx/arch/x86/src/qemu/qemu_vectors.S34
4 files changed, 77 insertions, 29 deletions
diff --git a/nuttx/arch/x86/include/i486/arch.h b/nuttx/arch/x86/include/i486/arch.h
index e2dde5555f..5910f08a15 100755
--- a/nuttx/arch/x86/include/i486/arch.h
+++ b/nuttx/arch/x86/include/i486/arch.h
@@ -163,6 +163,44 @@ static inline uint32_t up_getsp()
return regval;
}
+/* Get segment registers */
+
+static inline uint32_t up_getds()
+{
+ uint32_t regval;
+
+ asm volatile(
+ "\tmov %%ds, %0\n"
+ : "=rm" (regval)
+ :
+ : "memory");
+ return regval;
+}
+
+static inline uint32_t up_getcs()
+{
+ uint32_t regval;
+
+ asm volatile(
+ "\tmov %%cs, %0\n"
+ : "=rm" (regval)
+ :
+ : "memory");
+ return regval;
+}
+
+static inline uint32_t up_getss()
+{
+ uint32_t regval;
+
+ asm volatile(
+ "\tmov %%ss, %0\n"
+ : "=rm" (regval)
+ :
+ : "memory");
+ return regval;
+}
+
/****************************************************************************
* Public Types
****************************************************************************/
diff --git a/nuttx/arch/x86/src/i486/i486_utils.S b/nuttx/arch/x86/src/i486/i486_utils.S
index eae168fbd6..9010b5a711 100644
--- a/nuttx/arch/x86/src/i486/i486_utils.S
+++ b/nuttx/arch/x86/src/i486/i486_utils.S
@@ -52,6 +52,8 @@
# define SYMBOL(s) s
#endif
+#define KSEG 0x10
+
/****************************************************************************
* Nasm
****************************************************************************/
@@ -84,12 +86,12 @@ SYMBOL(gdt_flush):
mov eax, [esp+4] /* Get the pointer to the GDT, passed as a parameter */
lgdt [eax] /* Load the new GDT pointer */
- mov ax, 0x10 /* 0x10 is the offset in the GDT to our data segment */
- mov ds, ax /* Load all data segment selectors */
- mov es, ax
- mov fs, ax
- mov gs, ax
- mov ss, ax
+ mov $KSEG, ax /* KSEG is the offset in the GDT to our data segment */
+ mov ax, ds /* Load all data segment selectors */
+ mov ax, es
+ mov ax, fs
+ mov ax, gs
+ mov ax, ss
jmp 0x08:.gflush /* 0x08 is the offset to our code segment: Far jump! */
.gflush:
ret
@@ -135,12 +137,12 @@ SYMBOL(gdt_flush):
movl %eax, 4(%esp) /* Get the pointer to the GDT, passed as a parameter */
lgdt (%eax) /* Load the new GDT pointer */
- mov %ax, 0x10 /* 0x10 is the offset in the GDT to our data segment */
- mov %ds, %ax /* Load all data segment selectors */
- mov %es, %ax
- mov %fs, %ax
- mov %gs, %ax
- mov %ss, %ax
+ mov $KSEG, %ax /* KSEG is the offset in the GDT to our data segment */
+ mov %ax, %ds /* Load all data segment selectors */
+ mov %ax, %es
+ mov %ax, %fs
+ mov %ax, %gs
+ mov %ax, %ss
jmp $0x08, $.Lgflush /* 0x08 is the offset to our code segment: Far jump! */
.Lgflush:
ret
diff --git a/nuttx/arch/x86/src/i486/up_initialstate.c b/nuttx/arch/x86/src/i486/up_initialstate.c
index 6e7417d5c3..1a13b89915 100644
--- a/nuttx/arch/x86/src/i486/up_initialstate.c
+++ b/nuttx/arch/x86/src/i486/up_initialstate.c
@@ -93,6 +93,14 @@ void up_initial_state(_TCB *tcb)
xcp->regs[REG_EIP] = (uint32_t)tcb->start;
+ /* Set up the segment registers... assume the same segment as the caller.
+ * That is not a good assumption in the long run.
+ */
+
+ xcp->regs[REG_DS] = up_getds();
+ xcp->regs[REG_CS] = up_getcs();
+ xcp->regs[REG_SS] = up_getss();
+
/* Enable or disable interrupts, based on user configuration. If the IF
* bit is set, maskable interrupts will be enabled.
*/
diff --git a/nuttx/arch/x86/src/qemu/qemu_vectors.S b/nuttx/arch/x86/src/qemu/qemu_vectors.S
index 6795203e26..55aabaf39a 100755
--- a/nuttx/arch/x86/src/qemu/qemu_vectors.S
+++ b/nuttx/arch/x86/src/qemu/qemu_vectors.S
@@ -408,14 +408,14 @@ isr_common:
/* trace 'S' */
pusha /* Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax */
- mov %ax, %ds /* Lower 16-bits of eax = ds. */
+ mov %ds, %ax /* Lower 16-bits of eax = ds. */
pushl %eax /* Save the data segment descriptor */
- mov %ax, KSEG /* Load the kernel data segment descriptor */
- mov %ds, %ax
- mov %es, %ax
- mov %fs, %ax
- mov %gs, %ax
+ mov $KSEG, %ax /* Load the kernel data segment descriptor */
+ mov %ax, %ds
+ mov %ax, %es
+ mov %ax, %fs
+ mov %ax, %gs
/* The current value of the SP points to the beginning of the state save
* structure. Save that on the stack as the input parameter to isr_handler.
@@ -446,14 +446,14 @@ irq_common:
/* trace 'R' */
pusha /* Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax */
- mov %ax, %ds /* Lower 16-bits of eax = ds. */
+ mov %ds, %ax /* Lower 16-bits of eax = ds. */
push %eax /* Save the data segment descriptor */
- mov %ax, KSEG /* Load the kernel data segment descriptor */
- mov %ds, %ax
- mov %es, %ax
- mov %fs, %ax
- mov %gs, %ax
+ mov $KSEG, %ax /* Load the kernel data segment descriptor */
+ mov %ax, %ds
+ mov %ax, %es
+ mov %ax, %fs
+ mov %ax, %gs
/* The current value of the SP points to the beginning of the state save
* structure. Save that on the stack as the input parameter to irq_handler.
@@ -488,13 +488,13 @@ irq_common:
.Lnoswitch:
pop %ebx /* Reload the original data segment descriptor */
- mov %ds, %bx
- mov %es, %bx
- mov %fs, %bx
- mov %gs, %bx
+ mov %bx, %ds
+ mov %bx, %es
+ mov %bx, %fs
+ mov %bx, %gs
popa /* Pops edi,esi,ebp... */
- add %esp, 8 /* Cleans up the pushed error code and pushed ISR number */
+ add $8, %esp /* Cleans up the pushed error code and pushed ISR number */
sti
iret /* Pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP */
#ifndef __CYGWIN__