2 # Parent 4a8ebab4db51ea6b64c53788092f9565f0d4236a
4 diff -r 4a8ebab4db51 monitor.c
5 --- a/monitor.c Fri Aug 27 03:15:33 2010 -0400
6 +++ b/monitor.c Fri Aug 27 04:06:18 2010 -0400
7 @@ -1841,6 +1841,112 @@
12 +static void pg_print(Monitor *mon, uint32_t *pstart, int *plast_prot,
13 + uint32_t end, int prot,
14 + uint32_t *pde_next, int *pde_last_prot,
18 + prot1 = *plast_prot;
19 + if (prot != prot1) {
20 + if (*pstart != -1) {
21 + uint32_t pde_start = *pstart & ~((1 << 22) - 1);
22 + if (*pde_last_prot != pde_prot && pde_start >= *pde_next &&
23 + !(prot1 & PG_PSE_MASK)) {
24 + *pde_next = (end + ((1 << 22) - 1)) & ~((1 << 22) - 1);
25 + monitor_printf(mon, "PDE(%03x) %08x-%08x %08x %c%c%c\n",
26 + (*pde_next - pde_start) / (1 << 22),
27 + pde_start, *pde_next, *pde_next - pde_start,
28 + pde_prot & PG_USER_MASK ? 'u' : '-',
30 + pde_prot & PG_RW_MASK ? 'w' : '-');
34 + if (prot1 & PG_PSE_MASK) {
35 + monitor_printf(mon, " PDES(%03x) %08x-%08x %08x %c%c%c\n",
36 + (end - *pstart) / (1 << 22),
37 + *pstart, end, end - *pstart,
38 + prot1 & PG_USER_MASK ? 'u' : '-',
40 + prot1 & PG_RW_MASK ? 'w' : '-');
42 + monitor_printf(mon, " |-- PTE(%06x) %08x-%08x %08x %c%c%c\n",
43 + (end - *pstart) / (1 << 12),
44 + *pstart, end, end - *pstart,
45 + prot1 & PG_USER_MASK ? 'u' : '-',
47 + prot1 & PG_RW_MASK ? 'w' : '-');
58 +static void pg_info(Monitor *mon)
61 + int l1, l2, prot, last_prot;
62 + uint32_t pgd, pde, pte, start, end;
64 + int pde_prot, pde_last_prot;
65 + uint32_t pde_start, pde_end;
67 + env = mon_get_cpu();
71 + if (!(env->cr[0] & CR0_PG_MASK)) {
72 + monitor_printf(mon, "PG disabled\n");
75 + pgd = env->cr[3] & ~0xfff;
80 + for(l1 = 0; l1 < 1024; l1++) {
81 + cpu_physical_memory_read(pgd + l1 * 4, (uint8_t *)&pde, 4);
82 + pde = le32_to_cpu(pde);
85 + pde_prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
86 + if (pde & PG_PRESENT_MASK) {
87 + if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
88 + prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK |
90 + pg_print(mon, &start, &last_prot, end, prot,
91 + &pde_start, &pde_last_prot, pde_prot);
93 + for(l2 = 0; l2 < 1024; l2++) {
94 + cpu_physical_memory_read((pde & ~0xfff) + l2 * 4,
95 + (uint8_t *)&pte, 4);
96 + pte = le32_to_cpu(pte);
97 + end = (l1 << 22) + (l2 << 12);
98 + if (pte & PG_PRESENT_MASK) {
99 + prot = pte & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
103 + pg_print(mon, &start, &last_prot, end, prot,
104 + &pde_start, &pde_last_prot, pde_prot);
109 + pg_print(mon, &start, &last_prot, end, prot,
110 + &pde_start, &pde_last_prot, pde_prot);
114 + pg_print(mon, &start, &last_prot, 1024 << 22, 0,
115 + &pde_start, &pde_last_prot, pde_prot);
119 #if defined(TARGET_SH4)
120 @@ -2459,6 +2565,13 @@
121 .mhandler.info = mem_info,
127 + .help = "show the page table",
128 + .mhandler.info = pg_info,