The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/amd64/amd64/db_interface.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Mach Operating System
    3  * Copyright (c) 1991,1990 Carnegie Mellon University
    4  * All Rights Reserved.
    5  *
    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.
   11  *
   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.
   15  *
   16  * Carnegie Mellon requests users of this software to return to
   17  *
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  *
   23  * any improvements or extensions that they make and grant Carnegie the
   24  * rights to redistribute these changes.
   25  */
   26 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: releng/8.2/sys/amd64/amd64/db_interface.c 209505 2010-06-24 13:11:12Z jhb $");
   29 
   30 /*
   31  * Interface to new debugger.
   32  */
   33 #include <sys/param.h>
   34 #include <sys/systm.h>
   35 #include <sys/kdb.h>
   36 #include <sys/cons.h>
   37 #include <sys/pcpu.h>
   38 #include <sys/proc.h>
   39 
   40 #include <machine/cpu.h>
   41 
   42 #include <vm/vm.h>
   43 #include <vm/pmap.h>
   44 
   45 #include <ddb/ddb.h>
   46 
   47 /*
   48  * Read bytes from kernel address space for debugger.
   49  */
   50 int
   51 db_read_bytes(vm_offset_t addr, size_t size, char *data)
   52 {
   53         jmp_buf jb;
   54         void *prev_jb;
   55         char *src;
   56         int ret;
   57 
   58         prev_jb = kdb_jmpbuf(jb);
   59         ret = setjmp(jb);
   60         if (ret == 0) {
   61                 src = (char *)addr;
   62                 while (size-- > 0)
   63                         *data++ = *src++;
   64         }
   65         (void)kdb_jmpbuf(prev_jb);
   66         return (ret);
   67 }
   68 
   69 /*
   70  * Write bytes to kernel address space for debugger.
   71  */
   72 int
   73 db_write_bytes(vm_offset_t addr, size_t size, char *data)
   74 {
   75         jmp_buf jb;
   76         void *prev_jb;
   77         char *dst;
   78         pt_entry_t      *ptep0 = NULL;
   79         pt_entry_t      oldmap0 = 0;
   80         vm_offset_t     addr1;
   81         pt_entry_t      *ptep1 = NULL;
   82         pt_entry_t      oldmap1 = 0;
   83         int ret;
   84 
   85         prev_jb = kdb_jmpbuf(jb);
   86         ret = setjmp(jb);
   87         if (ret == 0) {
   88                 if (addr > trunc_page((vm_offset_t)btext) - size &&
   89                     addr < round_page((vm_offset_t)etext)) {
   90 
   91                         ptep0 = vtopte(addr);
   92                         oldmap0 = *ptep0;
   93                         *ptep0 |= PG_RW;
   94 
   95                         /*
   96                          * Map another page if the data crosses a page
   97                          * boundary.
   98                          */
   99                         if ((*ptep0 & PG_PS) == 0) {
  100                                 addr1 = trunc_page(addr + size - 1);
  101                                 if (trunc_page(addr) != addr1) {
  102                                         ptep1 = vtopte(addr1);
  103                                         oldmap1 = *ptep1;
  104                                         *ptep1 |= PG_RW;
  105                                 }
  106                         } else {
  107                                 addr1 = trunc_2mpage(addr + size - 1);
  108                                 if (trunc_2mpage(addr) != addr1) {
  109                                         ptep1 = vtopte(addr1);
  110                                         oldmap1 = *ptep1;
  111                                         *ptep1 |= PG_RW;
  112                                 }
  113                         }
  114 
  115                         invltlb();
  116                 }
  117 
  118                 dst = (char *)addr;
  119 
  120                 while (size-- > 0)
  121                         *dst++ = *data++;
  122         }
  123 
  124         (void)kdb_jmpbuf(prev_jb);
  125 
  126         if (ptep0) {
  127                 *ptep0 = oldmap0;
  128 
  129                 if (ptep1)
  130                         *ptep1 = oldmap1;
  131 
  132                 invltlb();
  133         }
  134 
  135         return (ret);
  136 }
  137 
  138 void
  139 db_show_mdpcpu(struct pcpu *pc)
  140 {
  141 
  142         db_printf("curpmap      = %p\n", pc->pc_curpmap);
  143         db_printf("tssp         = %p\n", pc->pc_tssp);
  144         db_printf("commontssp   = %p\n", pc->pc_commontssp);
  145         db_printf("rsp0         = 0x%lx\n", pc->pc_rsp0);
  146         db_printf("gs32p        = %p\n", pc->pc_gs32p);
  147         db_printf("ldt          = %p\n", pc->pc_ldt);
  148         db_printf("tss          = %p\n", pc->pc_tss);
  149 }

Cache object: 78d5091f02ba43172b750b5ba72ce7a1


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.