Annotation of OSKit-Mach/oskit/osenv_synch.c, revision 1.1

1.1     ! root        1: #include <oskit/dev/dev.h>
        !             2: 
        !             3: #include <machine/spl.h>
        !             4: #include "ds_oskit.h"
        !             5: 
        !             6: extern spl_t curr_ipl;
        !             7: 
        !             8: /*
        !             9:  * Enable/disable interrupts.
        !            10:  */
        !            11: 
        !            12: static spl_t osenv_intr_spl;
        !            13: 
        !            14: void
        !            15: osenv_intr_disable(void)
        !            16: {
        !            17:   /* We can be called with interrupts already disabled! */
        !            18:   if (curr_ipl > SPLIO)
        !            19:     /* We are already at higher priority than oskit code normally runs.
        !            20:        I think this only happens in the calls from oskit_rtc_{get,set}.
        !            21:        On the assumption that osenv_intr_enable will be called in
        !            22:        parity from the same interrupt level, we will want to stay at the
        !            23:        same high interrupt level.  */
        !            24:     osenv_intr_spl = curr_ipl;
        !            25:   else if (curr_ipl < SPLIO)
        !            26:     /* We are at a level where oskit interrupts are enabled, so we must go
        !            27:        to splio.  osenv_intr_enable we will return to the current level.  */
        !            28:     osenv_intr_spl = splio ();
        !            29: }
        !            30: 
        !            31: void
        !            32: osenv_intr_enable(void)
        !            33: {
        !            34:   /* We assume we are at splio or higher.  */
        !            35:   spl_t s = osenv_intr_spl;
        !            36:   osenv_intr_spl = SPL0;
        !            37:   splx (s);
        !            38: }
        !            39: 
        !            40: /*
        !            41:  * Return the current interrupt enable flag.
        !            42:  */
        !            43: int
        !            44: osenv_intr_enabled(void)
        !            45: {
        !            46:   return curr_ipl < SPLIO;
        !            47: }
        !            48: 
        !            49: /*
        !            50:  * Disable interrupts returning the old value.  Combo of:
        !            51:  *     save = osenv_intr_enabled();
        !            52:  *     osenv_intr_disable();
        !            53:  */
        !            54: int
        !            55: osenv_intr_save_disable(void)
        !            56: {
        !            57:   if (osenv_intr_enabled ())
        !            58:     {
        !            59:       osenv_intr_disable ();
        !            60:       return 1;
        !            61:     }
        !            62:   return 0;
        !            63: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.