Changeset 04803bf in mainline for kernel/arch/ia32/include/istate.h


Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes (needs fixes).

File:
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/include/istate.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup sync
     29/** @addtogroup ia32interrupt
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_RWLOCK_H_
    36 #define KERN_RWLOCK_H_
     35#ifndef KERN_ia32_ISTATE_H_
     36#define KERN_ia32_ISTATE_H_
    3737
    38 #include <arch/types.h>
    39 #include <synch/mutex.h>
    40 #include <synch/synch.h>
    41 #include <synch/spinlock.h>
     38#ifdef KERNEL
    4239
    43 typedef enum {
    44         RWLOCK_NONE,
    45         RWLOCK_READER,
    46         RWLOCK_WRITER
    47 } rwlock_type_t;
     40#include <typedefs.h>
     41#include <trace.h>
    4842
    49 typedef struct {
    50         SPINLOCK_DECLARE(lock);
    51         /**
    52          * Mutex for writers, readers can bypass it if readers_in is positive.
     43#else /* KERNEL */
     44
     45#include <sys/types.h>
     46
     47#define NO_TRACE
     48
     49#endif /* KERNEL */
     50
     51typedef struct istate {
     52        /*
     53         * The strange order of the GPRs is given by the requirement to use the
     54         * istate structure for both regular interrupts and exceptions as well
     55         * as for syscall handlers which use this order as an optimization.
    5356         */
    54         mutex_t exclusive;
    55         /** Number of readers in critical section. */
    56         size_t readers_in;
    57 } rwlock_t;
     57        uint32_t edx;
     58        uint32_t ecx;
     59        uint32_t ebx;
     60        uint32_t esi;
     61        uint32_t edi;
     62        uint32_t ebp;
     63        uint32_t eax;
     64       
     65        uint32_t ebp_frame;  /* imitation of frame pointer linkage */
     66        uint32_t eip_frame;  /* imitation of return address linkage */
     67       
     68        uint32_t gs;
     69        uint32_t fs;
     70        uint32_t es;
     71        uint32_t ds;
     72       
     73        uint32_t error_word;  /* real or fake error word */
     74        uint32_t eip;
     75        uint32_t cs;
     76        uint32_t eflags;
     77        uint32_t esp;         /* only if istate_t is from uspace */
     78        uint32_t ss;          /* only if istate_t is from uspace */
     79} istate_t;
    5880
    59 #define rwlock_write_lock(rwl) \
    60         _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    61 #define rwlock_read_lock(rwl) \
    62         _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    63 #define rwlock_write_trylock(rwl) \
    64         _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \
    65             SYNCH_FLAGS_NON_BLOCKING)
    66 #define rwlock_read_trylock(rwl) \
    67         _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \
    68             SYNCH_FLAGS_NON_BLOCKING)
    69 #define rwlock_write_lock_timeout(rwl, usec) \
    70         _rwlock_write_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE)
    71 #define rwlock_read_lock_timeout(rwl, usec) \
    72         _rwlock_read_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE)
     81/** Return true if exception happened while in userspace */
     82NO_TRACE static inline int istate_from_uspace(istate_t *istate)
     83{
     84        return !(istate->eip & UINT32_C(0x80000000));
     85}
    7386
    74 extern void rwlock_initialize(rwlock_t *rwl);
    75 extern void rwlock_read_unlock(rwlock_t *rwl);
    76 extern void rwlock_write_unlock(rwlock_t *rwl);
    77 extern int _rwlock_read_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags);
    78 extern int _rwlock_write_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags);
     87NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
     88    uintptr_t retaddr)
     89{
     90        istate->eip = retaddr;
     91}
     92
     93NO_TRACE static inline uintptr_t istate_get_pc(istate_t *istate)
     94{
     95        return istate->eip;
     96}
     97
     98NO_TRACE static inline uintptr_t istate_get_fp(istate_t *istate)
     99{
     100        return istate->ebp;
     101}
    79102
    80103#endif
Note: See TracChangeset for help on using the changeset viewer.