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/i386/i386/db_interface.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
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$");
   29 
   30 /*
   31  * Interface to new debugger.
   32  */
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/kdb.h>
   37 #include <sys/pcpu.h>
   38 #include <sys/proc.h>
   39 
   40 #include <machine/psl.h>
   41 
   42 #include <ddb/ddb.h>
   43 
   44 /*
   45  * Read bytes from kernel address space for debugger.
   46  */
   47 int
   48 db_read_bytes(vm_offset_t addr, size_t size, char *data)
   49 {
   50         jmp_buf jb;
   51         void *prev_jb;
   52         char *src;
   53         int ret;
   54 
   55         prev_jb = kdb_jmpbuf(jb);
   56         ret = setjmp(jb);
   57         if (ret == 0) {
   58                 src = (char *)addr;
   59                 while (size-- > 0)
   60                         *data++ = *src++;
   61         }
   62         (void)kdb_jmpbuf(prev_jb);
   63         return (ret);
   64 }
   65 
   66 /*
   67  * Write bytes to kernel address space for debugger.
   68  */
   69 int
   70 db_write_bytes(vm_offset_t addr, size_t size, char *data)
   71 {
   72         jmp_buf jb;
   73         void *prev_jb;
   74         char *dst;
   75         int ret;
   76 
   77         prev_jb = kdb_jmpbuf(jb);
   78         ret = setjmp(jb);
   79         if (ret == 0) {
   80                 dst = (char *)addr;
   81                 while (size-- > 0)
   82                         *dst++ = *data++;
   83         }
   84         (void)kdb_jmpbuf(prev_jb);
   85         return (ret);
   86 }
   87 
   88 int
   89 db_segsize(struct trapframe *tfp)
   90 {
   91         struct proc_ldt *plp;
   92         struct segment_descriptor *sdp;
   93         int sel;
   94 
   95         if (tfp == NULL)
   96             return (32);
   97         if (tfp->tf_eflags & PSL_VM)
   98             return (16);
   99         sel = tfp->tf_cs & 0xffff;
  100         if (sel == GSEL(GCODE_SEL, SEL_KPL))
  101             return (32);
  102         /* Rare cases follow.  User mode cases are currently unreachable. */
  103         if (ISLDT(sel)) {
  104             plp = curthread->td_proc->p_md.md_ldt;
  105             sdp = (plp != NULL) ? &plp->ldt_sd : &ldt[0].sd;
  106         } else {
  107             sdp = &gdt[PCPU_GET(cpuid) * NGDT].sd;
  108         }
  109         return (sdp[IDXSEL(sel)].sd_def32 == 0 ? 16 : 32);
  110 }
  111 
  112 void
  113 db_show_mdpcpu(struct pcpu *pc)
  114 {
  115 
  116         db_printf("APIC ID      = %d\n", pc->pc_apic_id);
  117         db_printf("currentldt   = 0x%x\n", pc->pc_currentldt);
  118         db_printf("trampstk     = 0x%x\n", pc->pc_trampstk);
  119         db_printf("kesp0        = 0x%x\n", pc->pc_kesp0);
  120         db_printf("common_tssp  = 0x%x\n", (u_int)pc->pc_common_tssp);
  121         db_printf("tlb gen      = %u\n", pc->pc_smp_tlb_done);
  122 }

Cache object: b238a0e0652f69608c644bdfa83c6019


[ 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.