summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gdbinit2
-rw-r--r--kc/core/cpu/cpu_task.S7
-rw-r--r--kc/core/pit8253.c4
3 files changed, 9 insertions, 4 deletions
diff --git a/.gdbinit b/.gdbinit
index 9faf2b9..7fc534d 100644
--- a/.gdbinit
+++ b/.gdbinit
@@ -1,3 +1,3 @@
target remote localhost:1234
-add-symbol-file kc/core/kernel.os 0xffffffff80001000 -s .data 0xffffffff80005000
+add-symbol-file kc/core/kernel.os 0xffffffff80001000 -s .data 0xffffffff80006000
diff --git a/kc/core/cpu/cpu_task.S b/kc/core/cpu/cpu_task.S
index f2fb473..4f9fd7b 100644
--- a/kc/core/cpu/cpu_task.S
+++ b/kc/core/cpu/cpu_task.S
@@ -17,6 +17,10 @@ cpu_set_thread:
* rsi: pointer to control block of the current thread
* rdx: pointer to this cpu's task state segment esp0 field
*/
+ // test for a NULL origin thread
+ test %rsi,%rsi
+ // skip saving the state for a NULL origin thread
+ jz .Lnull_thread
push %rbx
push %r12
push %r13
@@ -24,7 +28,8 @@ cpu_set_thread:
push %r15
push %rbp
/* the current task will be in rsi */
- mov %esp, 0(%rsi) // save the stack pointer for the current task
+ mov %rsp, 0(%rsi) // save the stack pointer for the current task
+.Lnull_thread:
mov 0(%rdi),%rsp // new stack is the next's task's stack
mov 8(%rdi),%rbx // top of the next task's kernel stack
mov %rbx,0(%rdx) // save the esp0 to the tss
diff --git a/kc/core/pit8253.c b/kc/core/pit8253.c
index 4728020..6f6256a 100644
--- a/kc/core/pit8253.c
+++ b/kc/core/pit8253.c
@@ -21,7 +21,7 @@
static void pit8253_set_divisor(uint16_t divisor);
-static atomic_uint_fast64_t count = 0;
+static volatile atomic_uint_fast64_t count = 0;
static uint16_t divisor = 0;
const struct timer_source pit8253_timer_source =
@@ -82,7 +82,7 @@ uint32_t pit8253_get_frequency(void)
uint64_t pit8253_nanoseconds_elapsed(void)
{
- return pit8253_nanoseconds_delta() * count;
+ return pit8253_nanoseconds_delta() * atomic_load(&count);
}
uint64_t pit8253_nanoseconds_delta(void)