diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-09-08 15:49:38 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-09-08 15:49:38 +0200 |
| commit | 4fdb0ed3a324adab8d752bdaa58b61ac445fea00 (patch) | |
| tree | d35e93c9971e903c6e3cac45acccb38c170abe9f /kernel/x86.c | |
| parent | 12b60a62e6d639f53d64f8a5823870070d8b467b (diff) | |
spinlocks
Diffstat (limited to 'kernel/x86.c')
| -rw-r--r-- | kernel/x86.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/kernel/x86.c b/kernel/x86.c index 7775ab7..15236a3 100644 --- a/kernel/x86.c +++ b/kernel/x86.c @@ -4,6 +4,10 @@ #include "lib/int/stdint.h" #include "lib/logger/log.h" +// +// suffix (b, w, l, q for byte, word, dword, and qword). +// + extern volatile uint64_t task_system_clock; // from task.c void sleep(int i) @@ -139,25 +143,19 @@ void x86_flush_tlb(uint32_t addr) } //xchg -volatile uint8_t x86_xchg(volatile uint8_t *addr, uint8_t val) +uint8_t x86_xchg(uint8_t *addr, uint8_t val) { - uint8_t result; - // test. because asm does not work !? - uint8_t oldval=*addr; - *addr=val; - return oldval; - + uint8_t result; - // The + in "+m" denotes a read-modify-write operand. - asm volatile("lock xchg %0, %1" : + asm volatile("lock xchgb %0, %1" : "+m" (*addr), "=a" (result) : "1" (val) : "cc"); //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"xchg val:%d with addr:0x%08X : result: %d",val,addr,result); -// + return result; } |
