Annotation of researchv9/sys/sun3/probe.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)probe.c 1.1 86/02/03 Copyr 1983 Sun Micro";
                      3: #endif
                      4: 
                      5: /*
                      6:  * Copyright (c) 1983 by Sun Microsystems, Inc.
                      7:  */
                      8: 
                      9: /*
                     10:  * Common routines for probing memory.
                     11:  * Typically called by drivers during initialization to
                     12:  * see if a device is present on the Mainbus.
                     13:  */
                     14: #include "../h/types.h"
                     15: #include "../machine/fault.h"
                     16: 
                     17: static label_t *saved_jb;
                     18: static label_t jb;
                     19: 
                     20: /*
                     21:  * Probe a location by attempting to read a word
                     22:  */
                     23: peek(a)
                     24:        short *a;
                     25: {
                     26:        int val;
                     27: 
                     28:        saved_jb = nofault;
                     29:        nofault = (label_t *)jb;
                     30:        if (!setjmp(jb)) {
                     31:                val = *a;
                     32:                /* if we get here, it worked */
                     33:                nofault = saved_jb;
                     34:                return (val & 0xFFFF);
                     35:        }
                     36:        /* A fault occured */
                     37:        nofault = saved_jb;
                     38:        return (-1);
                     39: }
                     40: 
                     41: /*
                     42:  * Probe a location by attempting to read a byte
                     43:  */
                     44: peekc(a)
                     45:        char *a;
                     46: {
                     47:        int val;
                     48: 
                     49:        saved_jb = nofault;
                     50:        nofault = (label_t *)jb;
                     51:        if (!setjmp(jb)) {
                     52:                val = *a;
                     53:                /* if we get here, it worked */
                     54:                nofault = saved_jb;
                     55:                return (val & 0xFF);
                     56:        }
                     57:        /* A fault occured */
                     58:        nofault = saved_jb;
                     59:        return (-1);
                     60: }
                     61: 
                     62: /*
                     63:  * Probe a location by attempting to write a word
                     64:  */
                     65: poke(a, val)
                     66:        short *a;
                     67:        short val;
                     68: {
                     69: 
                     70:        saved_jb = nofault;
                     71:        nofault = (label_t *)jb;
                     72:        if (!setjmp(jb)) {
                     73:                *a = val;
                     74:                /* if we get here, it worked */
                     75:                nofault = saved_jb;
                     76:                return (0);
                     77:        }
                     78:        /* A fault occured */
                     79:        nofault = saved_jb;
                     80:        return (1);
                     81: }
                     82: 
                     83: /*
                     84:  * Probe a location by attempting to write a byte
                     85:  */
                     86: pokec(a, val)
                     87:        char *a;
                     88:        char val;
                     89: {
                     90: 
                     91:        saved_jb = nofault;
                     92:        nofault = (label_t *)jb;
                     93:        if (!setjmp(jb)) {
                     94:                *a = val;
                     95:                /* if we get here, it worked */
                     96:                nofault = saved_jb;
                     97:                return (0);
                     98:        }
                     99:        /* A fault occured */
                    100:        nofault = saved_jb;
                    101:        return (1);
                    102: }

unix.superglobalmegacorp.com

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