1 /* $FreeBSD: releng/5.2/sys/powerpc/powerpc/db_memrw.c 104435 2002-10-04 01:19:18Z grehan $ */
2 /* $NetBSD: db_memrw.c,v 1.5 2001/12/27 10:25:41 dbj Exp $ */
3 /* $OpenBSD: db_memrw.c,v 1.2 1996/12/28 06:21:52 rahnds Exp $ */
4
5 /*
6 * Mach Operating System
7 * Copyright (c) 1992 Carnegie Mellon University
8 * All Rights Reserved.
9 *
10 * Permission to use, copy, modify and distribute this software and its
11 * documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie Mellon
28 * the rights to redistribute these changes.
29 */
30
31 /*
32 * Interface to the debugger for virtual memory read/write.
33 * This is a simple version for kernels with writable text.
34 * For an example of read-only kernel text, see the file:
35 * sys/arch/sun3/sun3/db_memrw.c
36 *
37 * ALERT! If you want to access device registers with a
38 * specific size, then the read/write functions have to
39 * make sure to do the correct sized pointer access.
40 */
41
42 #include <sys/param.h>
43 #include <sys/proc.h>
44
45 #include <vm/vm.h>
46 #include <vm/vm_extern.h>
47
48 #include <machine/db_machdep.h>
49
50 #include <ddb/ddb.h>
51
52 /*
53 * Read bytes from kernel address space for debugger.
54 */
55 void
56 db_read_bytes(addr, size, data)
57 vm_offset_t addr;
58 register size_t size;
59 register char *data;
60 {
61 register char *src = (char*)addr;
62
63 if (size == 4) {
64 *((int*)data) = *((int*)src);
65 return;
66 }
67
68 if (size == 2) {
69 *((short*)data) = *((short*)src);
70 return;
71 }
72
73 while (size > 0) {
74 --size;
75 *data++ = *src++;
76 }
77 }
78
79 /*
80 * Write bytes to kernel address space for debugger.
81 */
82 void
83 db_write_bytes(addr, size, data)
84 vm_offset_t addr;
85 register size_t size;
86 register char *data;
87 {
88 register char *dst = (char *)addr;
89
90 if (size == 4) {
91
92 *((int*)dst) = *((int*)data);
93
94 } else if (size == 2) {
95
96 *((short*)dst) = *((short*)data);
97
98 } else {
99
100 while (size > 0) {
101 --size;
102 *dst++ = *data++;
103 }
104
105 }
106
107 __syncicache((void *)addr, size);
108 }
109
Cache object: 2a1c66fd718d393b747e9dc36e87c0fd
|