Browse Source

Solved TOS addressing problem. This solves #615 issue (#812)

Added regress test and put order in test directory


Signed-off-by: fuchicar <rafita.fernandez@gmail.com>
Rafa 6 years ago
parent
commit
e0947d8b74

+ 2 - 2
sys/src/9/port/sysproc.c

@@ -434,7 +434,7 @@ execac(Ar0* ar0, int flags, char *ufile, char **argv)
 	/*
 	 * First, the top-of-stack structure.
 	 */
-	tos = (Tos*)stack;
+	tos = (Tos*)(USTKTOP-sizeof(Tos));
 	tos->cyclefreq = sys->cyclefreq;
 	cycles((uint64_t*)&tos->pcycles);
 	tos->pcycles = -tos->pcycles;
@@ -660,7 +660,7 @@ execac(Ar0* ar0, int flags, char *ufile, char **argv)
 		up->procctl = Proc_stopme;
 
 	/* we need to compte the value of &argv in user mode and then push that. */
-	ar0->v = sysexecregs(entry, TSTKTOP - PTR2UINT(argv), ((void *)tos) + (USTKTOP-TSTKTOP)/sizeof(void *));
+	ar0->v = sysexecregs(entry, TSTKTOP - PTR2UINT(argv), (void *)(USTKTOP-sizeof(Tos)));
 
 	if(flags == EXAC){
 		up->procctl = Proc_toac;

+ 1 - 3
sys/src/cmd/acme/acme.c

@@ -237,9 +237,7 @@ threadmain(int argc, char *argv[])
 
 	threadnotify(shutdown, 1);
 	recvul(cexit);
-	closekeyboard(keyboardctl);
-	closemouse(mousectl);
-	closedisplay(display);
+
 	killprocs();
 	threadexitsall(nil);
 }

+ 14 - 0
sys/src/regress/tos.c

@@ -0,0 +1,14 @@
+#include <u.h>
+#include <libc.h>
+#include <tos.h>
+
+void
+main(int argc, char *argv[]){
+  if (_tos == nil){
+    exits("FAIL");
+  }
+  if(getpid() == _tos->pid){
+    exits("OK");
+  }
+  exits("FAIL");
+}

+ 6 - 8
sys/src/test/build.json

@@ -1,13 +1,11 @@
 {
-  "Tests": {
-		"CFlags": [],
+	"Tests": {
 		"Include": [
-			"../cmd/cmd.json"
+			"/sys/src/cmd/cmd.json"
 		],
-    "Install": "/usr/harvey/",
-    "Program": "labels",
-    "SourceFiles": [
-			"labels.c"
+		"Install": "/$ARCH/bin/tests",
+		"SourceFilesCmd": [
+			"*.c"
 		]
-}
+	}
 }

+ 0 - 7
sys/src/test/hello/hello.c

@@ -1,7 +0,0 @@
-#include "hello.h"
-
-int main()
-{
-	printf("Be Galician!!\n");
-	return 0;
-}

+ 0 - 6
sys/src/test/hello/hello.h

@@ -1,6 +0,0 @@
-#ifndef _HELLO_TEST
-	#define _HELLO_TEST
-	#include <u.h>
-	#include <libc.h>
-	#include <stdio.h>
-#endif

+ 20 - 0
sys/src/test/pid.c

@@ -0,0 +1,20 @@
+#include <u.h>
+#include <libc.h>
+#include <tos.h>
+
+void
+main(int argc, char *argv[]){
+  if (_tos == nil){
+    exits("nil tos");
+  }
+  print("getpid() = <%d>\n", getpid());
+  print("Tos<%p>{\n"
+         "   cyclefreq <%u>\n"
+         "   kcycles   <%lld>\n"
+         "   pcycles   <%lld>\n"
+         "   pid       <%d>\n"
+         "   nixtype   <%d>\n"
+         "   core      <%d>\n"
+         "}\n",_tos, _tos->cyclefreq, _tos->kcycles, _tos->pcycles, _tos->pid, _tos->nixtype, _tos->core);
+  exits(nil);
+}

+ 0 - 11
sys/src/test/saymyname/say.c

@@ -1,11 +0,0 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
-
-void main()
-{
-	char nombre[25];
-	printf("Your name?: ");
-	scanf("%s", &nombre);
-	printf("\n\nHello %s\n",nombre);
-}

+ 0 - 20
sys/src/test/to_fork/to_fork.c

@@ -1,20 +0,0 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
-
-void main()
-{
-	int pid = fork();
-	if (pid == 0)
-	{
-		printf("I'm the father\n");
-	}
-	else if (pid > 0)
-	{
-		printf("I'm the child\n");
-	}
-	else
-	{
-		printf("fork() error\n");
-	}
-}