Browse Source

Fixes mkenumb and l64fpu functions, new cpuid

Elbing Miss 9 years ago
parent
commit
b9092f42e0
6 changed files with 36 additions and 35 deletions
  1. 1 4
      sys/src/9/k10/build.bash
  2. 19 13
      sys/src/9/k10/cpuidamd64.S
  3. 3 3
      sys/src/9/k10/entry.S
  4. 11 14
      sys/src/9/k10/l64fpu.S
  5. 1 1
      sys/src/9/k10/main.c
  6. 1 0
      sys/src/9/mk/mkenumb

+ 1 - 4
sys/src/9/k10/build.bash

@@ -50,10 +50,7 @@ compiling()
 	## Assembly world ##
 	##----------------##
 
-	# This is the wrong way to fix this. We need to fix the script. But it will do until we can.
-	$AWK -f ../mk/mkenumb amd64.h | sed 's/\([0-9][0-9a-fA-F]*\)ull/\1/' > amd64l.h # mkenumb is shell independent
-
-	# We don't want one of these (sipi.c depends on sipi.h from l64sipi.s)#
+	$AWK -f ../mk/mkenumb amd64.h > amd64l.h # mkenumb is shell independent
 
 	## Boot ##
 	##------##

+ 19 - 13
sys/src/9/k10/cpuidamd64.S

@@ -3,17 +3,23 @@
  */
 .globl cpuid
 cpuid:
-	MOVQ	%rdi, %rax
+	pushq	%rbp
+	movq	%rsp, %rbp
+	pushq	%rbx
+	movl	%edi, -12(%rbp)
+	movq	%rsi, -24(%rbp)
+	movq	%rdx, -32(%rbp)
+	movl	-12(%rbp), %eax
 
-	CPUID					/* argument in %rax */
+	cpuid 	/* Argument in %rax */
 
-	MOVQ	%rsi, %rbp
-#warning "multipel return"
-//	MOVL	%rax, 0(%rpb)
-//	MOVL	BX, 4(%rpb)
-//	MOVL	CX, 8(%rpb)
-//	MOVL	DX, 12(%rpb)
-	RET
+	movq	-24(%rbp), %rcx
+	movl	%eax, (%rcx)
+	movq	-32(%rbp), %rax
+	movl	%edx, (%rax)
+	popq	%rbx
+	popq	%rbp
+	ret
 
 /*
  * Basic timing loop to determine CPU frequency.
@@ -21,8 +27,8 @@ cpuid:
  */
 .globl aamloop
 aamloop:
-	MOVQ	%rdi, %rcx
+	movq	%rdi, %rcx
 aaml1:
-	XORQ	%rax, %rax				/* close enough */
-	LOOP	aaml1
-	RET
+	xorq	%rax, %rax				/* close enough */
+	loop	aaml1
+	ret

+ 3 - 3
sys/src/9/k10/entry.S

@@ -95,12 +95,12 @@ _endofheader:
 /*
  * Make the basic page tables for CPU0 to map 0-4MiB physical
  * to KZERO, and include an identity map for the switch from protected
- * to paging mode. There's an assumption here that the creation and later
+ * to paging mode. There`s an assumption here that the creation and later
  * removal of the identity map will not interfere with the KZERO mappings;
  * the conditions for clearing the identity map are
  *	clear PML4 entry when (KZER0 & 0x0000ff8000000000) != 0;
  *	clear PDP entry when (KZER0 & 0x0000007fc0000000) != 0;
- *	don't clear PD entry when (KZER0 & 0x000000003fe00000) == 0;
+ *	don`t clear PD entry when (KZER0 & 0x000000003fe00000) == 0;
  * the code below assumes these conditions are met.
  *
  * Assume a recent processor with Page Size Extensions
@@ -172,7 +172,7 @@ _warp64:
  *	set Long Mode Enable in the Extended Feature Enable MSR;
  *	set Paging Enable in CR0;
  *	make an inter-segment jump to the Long Mode code.
- * It's all in 32-bit mode until the jump is made.
+ * It`s all in 32-bit mode until the jump is made.
  */
 lme:
 	movl	%cr4, %eax

+ 11 - 14
sys/src/9/k10/l64fpu.S

@@ -8,49 +8,46 @@
 .globl _clts
 _clts:
 	CLTS
-	RET
+	ret
 
 .globl _fldcw
 _fldcw:
-//	MOVQ	%rdi, cw+0(FP)
-//	FLDCW	cw+0(FP)
-	RET
+	fldcw	(%rdi)
+	ret
 
 .globl _fnclex
 _fnclex:
 	FCLEX
-	RET
+	ret
 
 .globl _fninit
 _fninit:
 	FINIT					/* no WAIT */
-	RET
+	ret
 
 .globl _fxrstor
 _fxrstor:
 	FXRSTOR64 0(%rdi)
-	RET
+	ret
 
 .globl _fxsave
 _fxsave:
 	FXSAVE64 0(%rdi)
-	RET
+	ret
 
 .globl _fwait
 _fwait:
 	WAIT
-	RET
+	ret
 
 .globl _ldmxcsr
 _ldmxcsr:
-#warning "(FP)?"
-//	MOVQ	%rdi, mxcsr+0(FP)
-	//LDMXCSR	mxcsr+0(FP)
-	RET
+	LDMXCSR	(%rdi)
+	ret
 
 .globl _stts
 _stts:
 	MOVQ	%CR0, %rax
 	ORQ	$8, %rax				/* Ts */
 	MOVQ	%rax, %CR0
-	RET
+	ret

+ 1 - 1
sys/src/9/k10/main.c

@@ -500,7 +500,7 @@ userinit(void)
 	segpage(s, pg);
 	k = kmap(s->map[0]->pages[0]);
 	//memmove(UINT2PTR(VA(k)), initcode, sizeof(initcode));
-	memmove(UINT2PTR(VA(k)), initcode, sizeof(uint8_t));
+	memmove(UINT2PTR(VA(k)), init_out, sizeof(init_out));
 	kunmap(k);
 
 	ready(p);

+ 1 - 0
sys/src/9/mk/mkenumb

@@ -31,6 +31,7 @@ inenum && $0 ~ /^[ \t]+[_A-Za-z][_0-9A-Za-z]+[ \t]+=[ \t]+[0-9A-Z_a-z()<> ]+,/{
 	else
 		sep = tab;
 	split($3, a, ",");
+	gsub(/ull/, "", a[1])
 	printf "#define %s%s%s", $1, sep, a[1];
 	if(match($0, /\/\*.*\*\/$/)){
 		len = length(a[1]);