diff --git a/01-HelloOs/start.s b/01-HelloOs/start.s index aec0240..faa47b4 100644 --- a/01-HelloOs/start.s +++ b/01-HelloOs/start.s @@ -3,24 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - # we park the hart - - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間 diff --git a/02-ContextSwitch/start.s b/02-ContextSwitch/start.s index aec0240..faa47b4 100644 --- a/02-ContextSwitch/start.s +++ b/02-ContextSwitch/start.s @@ -3,24 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - # we park the hart - - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間 diff --git a/03-MultiTasking/start.s b/03-MultiTasking/start.s index aec0240..faa47b4 100644 --- a/03-MultiTasking/start.s +++ b/03-MultiTasking/start.s @@ -3,24 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - # we park the hart - - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間 diff --git a/04-TimerInterrupt/start.s b/04-TimerInterrupt/start.s index aec0240..faa47b4 100644 --- a/04-TimerInterrupt/start.s +++ b/04-TimerInterrupt/start.s @@ -3,24 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - # we park the hart - - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間 diff --git a/06-Spinlock/start.s b/06-Spinlock/start.s index aec0240..faa47b4 100644 --- a/06-Spinlock/start.s +++ b/06-Spinlock/start.s @@ -3,24 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - # we park the hart - - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間 diff --git a/07-ExterInterrupt/start.s b/07-ExterInterrupt/start.s index aec0240..faa47b4 100644 --- a/07-ExterInterrupt/start.s +++ b/07-ExterInterrupt/start.s @@ -3,24 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - # we park the hart - - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間 diff --git a/08-BlockDeviceDriver/start.s b/08-BlockDeviceDriver/start.s index aec0240..faa47b4 100644 --- a/08-BlockDeviceDriver/start.s +++ b/08-BlockDeviceDriver/start.s @@ -3,24 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - # we park the hart - - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間 diff --git a/09-MemoryAllocator/src/start.s b/09-MemoryAllocator/src/start.s index aec0240..faa47b4 100644 --- a/09-MemoryAllocator/src/start.s +++ b/09-MemoryAllocator/src/start.s @@ -3,24 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - # we park the hart - - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間 diff --git a/10-SystemCall/src/start.s b/10-SystemCall/src/start.s index e295645..faa47b4 100644 --- a/10-SystemCall/src/start.s +++ b/10-SystemCall/src/start.s @@ -3,32 +3,14 @@ .global _start _start: - # setup stacks per hart - csrr t0, mhartid # read current hart id - slli t0, t0, 10 # shift left the hart id by 1024 - la sp, stacks + STACK_SIZE # set the initial stack pointer - # to the end of the stack space - add sp, sp, t0 # move the current hart stack pointer - # to its place in the stack space - - # park harts with id != 0 - csrr a0, mhartid # read current hart id - bnez a0, park # if we're not on the hart 0 - -# li t0, 1 << 7 -# li t0, 0xffffffff -# csrw pmpaddr0, t0 -# li t0, 0xf -# csrw pmpcfg0, t0 -# csrr a1, mstatus -# or t0, t0, a1 -# csrw mstatus, t0 - # we park the hart - j os_main # hart 0 jump to c + csrr a0, mhartid # 讀取核心代號 + bnez a0, park # 若不是 0 號核心,跳到 park 停止 + la sp, stacks + STACK_SIZE # 0 號核心設定堆疊 + j os_main # 0 號核心跳到主程式 os_main park: wfi j park stacks: - .skip STACK_SIZE * 4 # allocate space for the harts stacks + .skip STACK_SIZE # 分配堆疊空間