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 $ */
6 * Mach Operating System
7 * Copyright (c) 1992 Carnegie Mellon University
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.
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.
20 * Carnegie Mellon requests users of this software to return to
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
27 * any improvements or extensions that they make and grant Carnegie Mellon
28 * the rights to redistribute these changes.
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
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.
42 #include <sys/param.h>
46 #include <vm/vm_extern.h>
48 #include <machine/cpu.h>
49 #include <machine/db_machdep.h>
54 * Read bytes from kernel address space for debugger.
57 db_read_bytes(addr, size, data)
62 register char *src = (char*)addr;
65 *((int*)data) = *((int*)src);
70 *((short*)data) = *((short*)src);
81 * Write bytes to kernel address space for debugger.
84 db_write_bytes(addr, size, data)
89 register char *dst = (char *)addr;
93 *((int*)dst) = *((int*)data);
95 } else if (size == 2) {
97 *((short*)dst) = *((short*)data);
108 __syncicache((void *)addr, size);