Annotation of Gnu-Mach/ddb/db_access.c, revision 1.1.1.3

1.1.1.2   root        1: /*
1.1       root        2:  * Mach Operating System
                      3:  * Copyright (c) 1991,1990 Carnegie Mellon University
                      4:  * All Rights Reserved.
1.1.1.2   root        5:  *
1.1       root        6:  * Permission to use, copy, modify and distribute this software and its
                      7:  * documentation is hereby granted, provided that both the copyright
                      8:  * notice and this permission notice appear in all copies of the
                      9:  * software, derivative works or modified versions, and any portions
                     10:  * thereof, and that both notices appear in supporting documentation.
1.1.1.2   root       11:  *
1.1       root       12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
1.1.1.2   root       15:  *
1.1       root       16:  * Carnegie Mellon requests users of this software to return to
1.1.1.2   root       17:  *
1.1       root       18:  *  Software Distribution Coordinator  or  [email protected]
                     19:  *  School of Computer Science
                     20:  *  Carnegie Mellon University
                     21:  *  Pittsburgh PA 15213-3890
1.1.1.2   root       22:  *
1.1       root       23:  * any improvements or extensions that they make and grant Carnegie Mellon
                     24:  * the rights to redistribute these changes.
                     25:  */
                     26: /*
                     27:  *     Author: David B. Golub, Carnegie Mellon University
                     28:  *     Date:   7/90
                     29:  */
1.1.1.3 ! root       30: 
1.1       root       31: #if MACH_KDB
                     32: 
                     33: #include <mach/boolean.h>
                     34: #include <machine/db_machdep.h>                /* type definitions */
1.1.1.3 ! root       35: #include <machine/db_interface.h>      /* function definitions */
1.1       root       36: #include <machine/setjmp.h>
                     37: #include <kern/task.h>
                     38: #include <ddb/db_access.h>
                     39: 
                     40: 
                     41: 
                     42: /*
                     43:  * Access unaligned data items on aligned (longword)
                     44:  * boundaries.
                     45:  */
                     46: 
                     47: int db_access_level = DB_ACCESS_LEVEL;
                     48: 
                     49: /*
                     50:  * This table is for sign-extending things.
                     51:  * Therefore its entries are signed, and yes
                     52:  * they are infact negative numbers.
                     53:  * So don't you put no more Us in it. Or Ls either.
                     54:  * Otherwise there is no point having it, n'est pas ?
                     55:  */
                     56: static int db_extend[sizeof(int)+1] = {        /* table for sign-extending */
                     57:        0,
                     58:        0xFFFFFF80,
                     59:        0xFFFF8000,
                     60:        0xFF800000,
                     61:        0x80000000
                     62: };
                     63: 
                     64: db_expr_t
                     65: db_get_task_value(addr, size, is_signed, task)
                     66:        db_addr_t       addr;
                     67:        register int    size;
                     68:        boolean_t       is_signed;
                     69:        task_t          task;
                     70: {
                     71:        char            data[sizeof(db_expr_t)];
                     72:        register db_expr_t value;
                     73:        register int    i;
                     74: 
1.1.1.3 ! root       75:        db_read_bytes(addr, size, data, task);
1.1       root       76: 
                     77:        value = 0;
                     78: #if    BYTE_MSF
                     79:        for (i = 0; i < size; i++)
                     80: #else  /* BYTE_LSF */
                     81:        for (i = size - 1; i >= 0; i--)
                     82: #endif
                     83:        {
                     84:            value = (value << 8) + (data[i] & 0xFF);
                     85:        }
1.1.1.2   root       86: 
1.1       root       87:        if (size <= sizeof(int)) {
                     88:            if (is_signed && (value & db_extend[size]) != 0)
                     89:                value |= db_extend[size];
                     90:        }
                     91:        return (value);
                     92: }
                     93: 
                     94: void
                     95: db_put_task_value(addr, size, value, task)
                     96:        db_addr_t       addr;
                     97:        register int    size;
                     98:        register db_expr_t value;
                     99:        task_t          task;
                    100: {
                    101:        char            data[sizeof(db_expr_t)];
                    102:        register int    i;
                    103: 
                    104: #if    BYTE_MSF
                    105:        for (i = size - 1; i >= 0; i--)
                    106: #else  /* BYTE_LSF */
                    107:        for (i = 0; i < size; i++)
                    108: #endif
                    109:        {
                    110:            data[i] = value & 0xFF;
                    111:            value >>= 8;
                    112:        }
                    113: 
1.1.1.3 ! root      114:        db_write_bytes(addr, size, data, task);
1.1       root      115: }
                    116: 
                    117: db_expr_t
                    118: db_get_value(addr, size, is_signed)
                    119:        db_addr_t       addr;
                    120:        int             size;
                    121:        boolean_t       is_signed;
                    122: {
                    123:        return(db_get_task_value(addr, size, is_signed, TASK_NULL));
                    124: }
                    125: 
                    126: void
                    127: db_put_value(addr, size, value)
                    128:        db_addr_t       addr;
                    129:        int             size;
                    130:        db_expr_t       value;
                    131: {
                    132:        db_put_task_value(addr, size, value, TASK_NULL);
                    133: }
                    134: 
1.1.1.2   root      135: #endif /* MACH_KDB */

unix.superglobalmegacorp.com

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