Support O2 optimization
This commit is contained in:
@@ -31,32 +31,14 @@ Modification:
|
||||
|
||||
context_switch:
|
||||
# store original context to stack
|
||||
str lr, [r13, #-4]!
|
||||
str r12, [r13, #-4]!
|
||||
str r11, [r13, #-4]!
|
||||
str r10, [r13, #-4]!
|
||||
str r9, [r13, #-4]!
|
||||
str r8, [r13, #-4]!
|
||||
str r7, [r13, #-4]!
|
||||
str r6, [r13, #-4]!
|
||||
str r5, [r13, #-4]!
|
||||
str r4, [r13, #-4]!
|
||||
stmfd r13!, {r4-r12, lr}
|
||||
|
||||
# switch the stack
|
||||
str r13, [r0] // save current sp to the old PCB (**old)
|
||||
mov r13, r1 // load the next stack
|
||||
|
||||
# restore context from stack
|
||||
ldr r4, [r13], #4
|
||||
ldr r5, [r13], #4
|
||||
ldr r6, [r13], #4
|
||||
ldr r7, [r13], #4
|
||||
ldr r8, [r13], #4
|
||||
ldr r9, [r13], #4
|
||||
ldr r10, [r13], #4
|
||||
ldr r11, [r13], #4
|
||||
ldr r12, [r13], #4
|
||||
ldr lr, [r13], #4
|
||||
ldmfd r13!, {r4-r12, lr}
|
||||
|
||||
# return to the caller
|
||||
bx lr
|
||||
|
||||
@@ -76,7 +76,7 @@ Modification:
|
||||
|
||||
#define NR_CPU 4
|
||||
|
||||
__attribute__((always_inline)) static inline uint32_t user_mode()
|
||||
__attribute__((always_inline, optimize("O0"))) static inline uint32_t user_mode()
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
@@ -103,12 +103,12 @@ struct context {
|
||||
uint32_t r11;
|
||||
uint32_t r12;
|
||||
uint32_t lr;
|
||||
};
|
||||
} __attribute__((packed));
|
||||
|
||||
/// @brief init task context, set return address to trap return
|
||||
/// @param
|
||||
extern void task_prepare_enter();
|
||||
__attribute__((__always_inline__)) static inline void arch_init_context(struct context* ctx)
|
||||
__attribute__((always_inline, optimize("O0"))) static inline void arch_init_context(struct context* ctx)
|
||||
{
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
ctx->lr = (uint32_t)(task_prepare_enter + 4);
|
||||
@@ -133,13 +133,13 @@ struct trapframe {
|
||||
uint32_t r11;
|
||||
uint32_t r12;
|
||||
uint32_t pc;
|
||||
};
|
||||
} __attribute__((packed));
|
||||
|
||||
/// @brief init task trapframe (*especially the user mode cpsr)
|
||||
/// @param tf
|
||||
/// @param sp
|
||||
/// @param pc
|
||||
__attribute__((__always_inline__)) static inline void arch_init_trapframe(struct trapframe* tf, uintptr_t sp, uintptr_t pc)
|
||||
__attribute__((always_inline, optimize("O0"))) static inline void arch_init_trapframe(struct trapframe* tf, uintptr_t sp, uintptr_t pc)
|
||||
{
|
||||
memset(tf, 0, sizeof(*tf));
|
||||
tf->spsr = user_mode();
|
||||
@@ -153,7 +153,7 @@ __attribute__((__always_inline__)) static inline void arch_init_trapframe(struct
|
||||
/// @param tf
|
||||
/// @param sp
|
||||
/// @param pc
|
||||
__attribute__((__always_inline__)) static inline void arch_trapframe_set_sp_pc(struct trapframe* tf, uintptr_t sp, uintptr_t pc)
|
||||
__attribute__((always_inline, optimize("O0"))) static inline void arch_trapframe_set_sp_pc(struct trapframe* tf, uintptr_t sp, uintptr_t pc)
|
||||
{
|
||||
tf->sp_usr = sp;
|
||||
tf->pc = pc;
|
||||
@@ -163,7 +163,7 @@ __attribute__((__always_inline__)) static inline void arch_trapframe_set_sp_pc(s
|
||||
/// @param tf
|
||||
/// @param argc
|
||||
/// @param argv
|
||||
__attribute__((__always_inline__)) static inline void arch_set_main_params(struct trapframe* tf, int argc, uintptr_t argv)
|
||||
__attribute__((always_inline, optimize("O0"))) static inline void arch_set_main_params(struct trapframe* tf, int argc, uintptr_t argv)
|
||||
{
|
||||
tf->r0 = (uint32_t)argc;
|
||||
tf->r1 = (uint32_t)argv;
|
||||
@@ -178,7 +178,7 @@ __attribute__((__always_inline__)) static inline void arch_set_main_params(struc
|
||||
/// @param param5
|
||||
/// @return
|
||||
extern int syscall(int sys_num, uintptr_t param1, uintptr_t param2, uintptr_t param3, uintptr_t param4);
|
||||
__attribute__((__always_inline__)) static inline int arch_syscall(struct trapframe* tf, int* syscall_num)
|
||||
__attribute__((always_inline, optimize("O0"))) static inline int arch_syscall(struct trapframe* tf, int* syscall_num)
|
||||
{
|
||||
// call syscall
|
||||
*syscall_num = tf->r0;
|
||||
@@ -188,7 +188,7 @@ __attribute__((__always_inline__)) static inline int arch_syscall(struct trapfra
|
||||
/// @brief set return reg to trapframe
|
||||
/// @param tf
|
||||
/// @param ret
|
||||
__attribute__((__always_inline__)) static inline void arch_set_return(struct trapframe* tf, int ret)
|
||||
__attribute__((always_inline, optimize("O0"))) static inline void arch_set_return(struct trapframe* tf, int ret)
|
||||
{
|
||||
tf->r0 = (uint32_t)ret;
|
||||
}
|
||||
|
||||
+5
-1
@@ -45,6 +45,8 @@ Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. take only gicd part of functions
|
||||
*************************************************/
|
||||
#include "string.h"
|
||||
|
||||
#include "gicv2_common_opa.h"
|
||||
#include "gicv2_registers.h"
|
||||
|
||||
@@ -139,7 +141,7 @@ void gic_send_sgi(uint32_t irqID, uint32_t target_list, uint32_t filter_list)
|
||||
|
||||
void gic_init(void)
|
||||
{
|
||||
gicd_t* gicd = gic_get_gicd();
|
||||
volatile gicd_t* gicd = gic_get_gicd();
|
||||
|
||||
// First disable the distributor.
|
||||
gic_enable(false);
|
||||
@@ -150,7 +152,9 @@ void gic_init(void)
|
||||
|
||||
for (uint32_t i = 0; i < 255; i++) {
|
||||
*(uint32_t*)(&gicd->IPRIORITYRn[i * sizeof(uint32_t)]) = (uint32_t)0x80808080;
|
||||
// memset((void*)&gicd->IPRIORITYRn[i * sizeof(uint32_t)], 0x80, sizeof(uint32_t));
|
||||
*(uint32_t*)(&gicd->ITARGETSRn[i * sizeof(uint32_t)]) = (uint32_t)0x01010101;
|
||||
// memset((void*)&gicd->IPRIORITYRn[i * sizeof(uint32_t)], 0x01, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
// Init the GIC CPU interface.
|
||||
|
||||
@@ -52,7 +52,7 @@ enum {
|
||||
SPINLOCK_LOCK_WAITFOREVER = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
void spinlock_init(struct spinlock* lock, char* name)
|
||||
__attribute__((optimize("O0"))) void spinlock_init(struct spinlock* lock, char* name)
|
||||
{
|
||||
lock->owner_cpu = SPINLOCK_STATE_UNLOCK;
|
||||
strncpy(lock->name, name, 24);
|
||||
@@ -61,7 +61,7 @@ void spinlock_init(struct spinlock* lock, char* name)
|
||||
extern int _spinlock_lock(struct spinlock* lock, uint32_t timeout);
|
||||
void _spinlock_unlock(struct spinlock* lock);
|
||||
|
||||
void spinlock_lock(struct spinlock* lock)
|
||||
__attribute__((optimize("O0"))) void spinlock_lock(struct spinlock* lock)
|
||||
{
|
||||
int cur_cpu_id = cur_cpuid();
|
||||
if (lock->owner_cpu != SPINLOCK_STATE_UNLOCK && lock->owner_cpu == cur_cpu_id) {
|
||||
@@ -80,7 +80,7 @@ void spinlock_lock(struct spinlock* lock)
|
||||
_spinlock_lock(lock, SPINLOCK_LOCK_WAITFOREVER);
|
||||
}
|
||||
|
||||
void spinlock_unlock(struct spinlock* lock)
|
||||
__attribute__((optimize("O0"))) void spinlock_unlock(struct spinlock* lock)
|
||||
{
|
||||
struct double_list_node* p_lock_node = &core_lock_request[cur_cpuid()].node;
|
||||
assert(lock_request_guard.next == p_lock_node);
|
||||
@@ -91,7 +91,7 @@ void spinlock_unlock(struct spinlock* lock)
|
||||
_spinlock_unlock(lock);
|
||||
}
|
||||
|
||||
bool spinlock_try_lock(struct spinlock* lock)
|
||||
__attribute__((optimize("O0"))) bool spinlock_try_lock(struct spinlock* lock)
|
||||
{
|
||||
int cur_cpu_id = cur_cpuid();
|
||||
if (lock->owner_cpu != SPINLOCK_STATE_UNLOCK && lock->owner_cpu == cur_cpu_id) {
|
||||
|
||||
Reference in New Issue
Block a user