aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exceptions/svc.S2
-rw-r--r--src/sys/kernel.S7
-rw-r--r--src/tests/test.c58
3 files changed, 37 insertions, 30 deletions
diff --git a/src/exceptions/svc.S b/src/exceptions/svc.S
index ce3e556..a24bac9 100644
--- a/src/exceptions/svc.S
+++ b/src/exceptions/svc.S
@@ -125,7 +125,7 @@ svc_000008: // Semaphore add #
b schedule
b svc_exit
svc_000009: // SYS_TIME_2
- mrc p15, 0, r0, c14, c3, 0
+ mrc p15, 0, r0, c9, c13, 0
str r0, [sp, #0]
b svc_exit
svc_exit:
diff --git a/src/sys/kernel.S b/src/sys/kernel.S
index 8793d84..71b22a1 100644
--- a/src/sys/kernel.S
+++ b/src/sys/kernel.S
@@ -11,6 +11,13 @@ kernel_main:
mov r1, #0
mov r3, #0xFF00
bl draw_cstring
+ // Initialize System Cycle Counter
+ mov r0, #1
+ mcr p15, 0, r0, c9, c14, 0
+ mov r0, #1
+ mcr p15, 0, r0, c9, c12, 0
+ mov r0, #0x80000000
+ mcr p15, 0, r0, c9, c12, 1
// Intentional undefined instruction
// .word 0xf7f0a000
diff --git a/src/tests/test.c b/src/tests/test.c
index b6ba5d3..69c150e 100644
--- a/src/tests/test.c
+++ b/src/tests/test.c
@@ -39,11 +39,11 @@ void test_entry(void)
bins[i] = 0;
}
- // Test 1: Tracing Time
+ // Test 2: Yield Time
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
- sys0_32(SYS_TIME_2, &tf);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &ti);
+ sys0_64(SYS_TIME, &tf);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
bins[(tf-ti)]++;
@@ -63,9 +63,9 @@ void test_entry(void)
// Test 2: Yield Time
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
sys0(SYS_YIELD);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
bins[(tf-ti)]++;
@@ -85,9 +85,9 @@ void test_entry(void)
// Test 3: Add Thread, Lower Priority
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
add_thread(nooptest, 0, 3);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
bins[(tf-ti)]++;
@@ -107,9 +107,9 @@ void test_entry(void)
// Test 4: Add Thread, Higher Priority
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
add_thread(nooptest, 0, 0);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
bins[(tf-ti)]++;
@@ -129,9 +129,9 @@ void test_entry(void)
// Test 5: Create Mutex
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
struct Mutex* m = create_mutex(0);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
delete_mutex(m);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
@@ -153,9 +153,9 @@ void test_entry(void)
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
struct Mutex* m = create_mutex(0);
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
delete_mutex(m);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
bins[(tf-ti)]++;
@@ -176,9 +176,9 @@ void test_entry(void)
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
struct Mutex* m = create_mutex(0);
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
lock_mutex(m);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
delete_mutex(m);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
@@ -202,9 +202,9 @@ void test_entry(void)
struct Mutex* m = create_mutex(0);
add_thread(mutex_contention_helper, m, 2);
sys0(SYS_YIELD);
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
lock_mutex(m);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
delete_mutex(m);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
@@ -227,9 +227,9 @@ void test_entry(void)
for(int i = 0; i < TEST_COUNT; i++) {
struct Mutex* m = create_mutex(0);
lock_mutex(m);
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
unlock_mutex(m);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
delete_mutex(m);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
@@ -254,9 +254,9 @@ void test_entry(void)
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
sem = 1;
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
sys1(SYS_SEMAPHORE_P, &sem);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
bins[(tf-ti)]++;
@@ -277,9 +277,9 @@ void test_entry(void)
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
sem = 0;
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
sys1(SYS_SEMAPHORE_V, &sem);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
bins[(tf-ti)]++;
@@ -300,9 +300,9 @@ void test_entry(void)
dt = 0;
for(int i = 0; i < TEST_COUNT; i++) {
sem = 1;
- sys0_32(SYS_TIME_2, &tf);
+ sys0_64(SYS_TIME, &ti);
sys1(SYS_SEMAPHORE_V, &sem);
- sys0_32(SYS_TIME_2, &ti);
+ sys0_64(SYS_TIME, &tf);
dt += tf - ti;
if ((tf-ti) < TEST_BIN_COUNT)
bins[(tf-ti)]++;
@@ -322,18 +322,18 @@ void test_entry(void)
// // Test 7: Tick Latency
//#define DELAY_TIME 512000
// unsigned long center = 0;
-// sys0_32(SYS_TIME_2, &tf);
+// sys0_64(SYS_TIME, &ti);
// delay(DELAY_TIME);
-// sys0_32(SYS_TIME_2, &ti);
+// sys0_64(SYS_TIME, &tf);
// center = (tf - ti - 10);
// if (10 > (tf-ti))
// center = 0;
// dt = 0;
// unsigned long j = 0;
// for(int i = 0; i < TEST_COUNT; i++) {
-// sys0_32(SYS_TIME_2, &tf);
+// sys0_64(SYS_TIME, &ti);
// delay(DELAY_TIME);
-// sys0_32(SYS_TIME_2, &ti);
+// sys0_64(SYS_TIME, &tf);
// dt += tf - ti;
// if ((tf-ti-center) < TEST_BIN_COUNT)
// bins[(tf-ti)-center]++;