2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
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.
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie the
24 * rights to redistribute these changes.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
31 * Interface to new debugger.
33 #include <sys/param.h>
34 #include <sys/systm.h>
40 #include <machine/cpu.h>
48 * Read bytes from kernel address space for debugger.
51 db_read_bytes(vm_offset_t addr, size_t size, char *data)
58 prev_jb = kdb_jmpbuf(jb);
65 (void)kdb_jmpbuf(prev_jb);
70 * Write bytes to kernel address space for debugger.
73 db_write_bytes(vm_offset_t addr, size_t size, char *data)
78 pt_entry_t *ptep0 = NULL;
79 pt_entry_t oldmap0 = 0;
81 pt_entry_t *ptep1 = NULL;
82 pt_entry_t oldmap1 = 0;
85 prev_jb = kdb_jmpbuf(jb);
88 if (addr > trunc_page((vm_offset_t)btext) - size &&
89 addr < round_page((vm_offset_t)etext)) {
96 * Map another page if the data crosses a page
99 if ((*ptep0 & PG_PS) == 0) {
100 addr1 = trunc_page(addr + size - 1);
101 if (trunc_page(addr) != addr1) {
102 ptep1 = vtopte(addr1);
107 addr1 = trunc_2mpage(addr + size - 1);
108 if (trunc_2mpage(addr) != addr1) {
109 ptep1 = vtopte(addr1);
124 (void)kdb_jmpbuf(prev_jb);
139 db_show_mdpcpu(struct pcpu *pc)
143 db_printf("currentldt = 0x%x\n", pc->pc_currentldt);