|
|
1.1 ! root 1: /* ! 2: * Mach Operating System ! 3: * Copyright (c) 1991,1990 Carnegie Mellon University ! 4: * All Rights Reserved. ! 5: * ! 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. ! 11: * ! 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. ! 15: * ! 16: * Carnegie Mellon requests users of this software to return to ! 17: * ! 18: * Software Distribution Coordinator or [email protected] ! 19: * School of Computer Science ! 20: * Carnegie Mellon University ! 21: * Pittsburgh PA 15213-3890 ! 22: * ! 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: */ ! 30: #include "mach_kdb.h" ! 31: #if MACH_KDB ! 32: ! 33: #include <mach/boolean.h> ! 34: #include <machine/db_machdep.h> /* type definitions */ ! 35: #include <machine/setjmp.h> ! 36: #include <kern/task.h> ! 37: #include <ddb/db_access.h> ! 38: ! 39: ! 40: ! 41: /* ! 42: * Access unaligned data items on aligned (longword) ! 43: * boundaries. ! 44: */ ! 45: ! 46: extern void db_read_bytes(); /* machine-dependent */ ! 47: extern void db_write_bytes(); /* machine-dependent */ ! 48: ! 49: int db_access_level = DB_ACCESS_LEVEL; ! 50: ! 51: /* ! 52: * This table is for sign-extending things. ! 53: * Therefore its entries are signed, and yes ! 54: * they are infact negative numbers. ! 55: * So don't you put no more Us in it. Or Ls either. ! 56: * Otherwise there is no point having it, n'est pas ? ! 57: */ ! 58: static int db_extend[sizeof(int)+1] = { /* table for sign-extending */ ! 59: 0, ! 60: 0xFFFFFF80, ! 61: 0xFFFF8000, ! 62: 0xFF800000, ! 63: 0x80000000 ! 64: }; ! 65: ! 66: db_expr_t ! 67: db_get_task_value(addr, size, is_signed, task) ! 68: db_addr_t addr; ! 69: register int size; ! 70: boolean_t is_signed; ! 71: task_t task; ! 72: { ! 73: char data[sizeof(db_expr_t)]; ! 74: register db_expr_t value; ! 75: register int i; ! 76: ! 77: db_read_bytes((void*)addr, size, data, task); ! 78: ! 79: value = 0; ! 80: #if BYTE_MSF ! 81: for (i = 0; i < size; i++) ! 82: #else /* BYTE_LSF */ ! 83: for (i = size - 1; i >= 0; i--) ! 84: #endif ! 85: { ! 86: value = (value << 8) + (data[i] & 0xFF); ! 87: } ! 88: ! 89: if (size <= sizeof(int)) { ! 90: if (is_signed && (value & db_extend[size]) != 0) ! 91: value |= db_extend[size]; ! 92: } ! 93: return (value); ! 94: } ! 95: ! 96: void ! 97: db_put_task_value(addr, size, value, task) ! 98: db_addr_t addr; ! 99: register int size; ! 100: register db_expr_t value; ! 101: task_t task; ! 102: { ! 103: char data[sizeof(db_expr_t)]; ! 104: register int i; ! 105: ! 106: #if BYTE_MSF ! 107: for (i = size - 1; i >= 0; i--) ! 108: #else /* BYTE_LSF */ ! 109: for (i = 0; i < size; i++) ! 110: #endif ! 111: { ! 112: data[i] = value & 0xFF; ! 113: value >>= 8; ! 114: } ! 115: ! 116: db_write_bytes((void*)addr, size, data, task); ! 117: } ! 118: ! 119: db_expr_t ! 120: db_get_value(addr, size, is_signed) ! 121: db_addr_t addr; ! 122: int size; ! 123: boolean_t is_signed; ! 124: { ! 125: return(db_get_task_value(addr, size, is_signed, TASK_NULL)); ! 126: } ! 127: ! 128: void ! 129: db_put_value(addr, size, value) ! 130: db_addr_t addr; ! 131: int size; ! 132: db_expr_t value; ! 133: { ! 134: db_put_task_value(addr, size, value, TASK_NULL); ! 135: } ! 136: ! 137: #endif MACH_KDB
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.