Changeset 98


Ignore:
Timestamp:
Jun 29, 2017, 2:27:35 PM (7 years ago)
Author:
max@…
Message:

add the and/or ops

Location:
trunk/hal/x86_64/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/core/hal_cpu.S

    r97 r98  
    111111        ret
    112112
     113ASM_ENTRY(atomic_and_32)
     114        movl    (%rdi),%eax
     1151:
     116        movl    %eax,%ecx
     117        andl    %esi,%ecx
     118        lock
     119        cmpxchgl %ecx,(%rdi)
     120        jnz     1b
     121        /* %eax now contains the old value */
     122        ret
     123
     124ASM_ENTRY(atomic_or_32)
     125        movl    (%rdi),%eax
     1261:
     127        movl    %eax,%ecx
     128        orl     %esi,%ecx
     129        lock
     130        cmpxchgl %ecx,(%rdi)
     131        jnz     1b
     132        /* %eax now contains the old value */
     133        ret
     134
  • trunk/hal/x86_64/core/hal_internal.h

    r96 r98  
    4343uint32_t atomic_cas_32(volatile uint32_t *ptr, uint32_t exp, uint32_t new);
    4444uint32_t atomic_add_32(volatile uint32_t *ptr, int32_t incr);
     45uint32_t atomic_and_32(volatile uint32_t *ptr, uint32_t mask);
     46uint32_t atomic_or_32(volatile uint32_t *ptr, uint32_t mask);
    4547
    4648/* hal_gpt.c */
  • trunk/hal/x86_64/core/hal_remote.c

    r96 r98  
    8686                                uint32_t mask )
    8787{
    88         x86_panic((char *)__func__);
    89         return 0;
     88        return atomic_and_32((volatile uint32_t *)xp, mask);
    9089}
    9190
     
    9392                               uint32_t mask )
    9493{
    95         x86_panic((char *)__func__);
    96         return 0;
     94        return atomic_or_32((volatile uint32_t *)xp, mask);
    9795}
    9896
Note: See TracChangeset for help on using the changeset viewer.