|
|
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
1.1.1.4 ! root 65: db_get_task_value(
! 66: db_addr_t addr,
! 67: int size,
! 68: boolean_t is_signed,
! 69: task_t task)
1.1 root 70: {
71: char data[sizeof(db_expr_t)];
1.1.1.4 ! root 72: db_expr_t value;
! 73: int i;
1.1 root 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
1.1.1.4 ! root 95: db_put_task_value(
! 96: db_addr_t addr,
! 97: int size,
! 98: db_expr_t value,
! 99: task_t task)
1.1 root 100: {
101: char data[sizeof(db_expr_t)];
1.1.1.4 ! root 102: int i;
1.1 root 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
1.1.1.4 ! root 118: db_get_value(
! 119: db_addr_t addr,
! 120: int size,
! 121: boolean_t is_signed)
1.1 root 122: {
123: return(db_get_task_value(addr, size, is_signed, TASK_NULL));
124: }
125:
126: void
1.1.1.4 ! root 127: db_put_value(
! 128: db_addr_t addr,
! 129: int size,
! 130: db_expr_t value)
1.1 root 131: {
132: db_put_task_value(addr, size, value, TASK_NULL);
133: }
134:
1.1.1.2 root 135: #endif /* MACH_KDB */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.