Skip to content

Instantly share code, notes, and snippets.

@nullnilaki
Last active January 4, 2016 11:39
Show Gist options
  • Save nullnilaki/8616169 to your computer and use it in GitHub Desktop.
Save nullnilaki/8616169 to your computer and use it in GitHub Desktop.
paddr_t
__C(CHIP,_mem_mmap)(
void *v,
bus_addr_t addr,
off_t off,
int prot,
int flags)
{
printf("map addr %lx\n",addr);
printf("map off %lx\n",off);
printf("map p_k %lx\n",ALPHA_PHYS_TO_K0SEG(CHIP_MEM_SYS_START(v) + addr + off));
printf("map ret %lx\n", alpha_btop(ALPHA_PHYS_TO_K0SEG(CHIP_MEM_SYS_START(v) + addr + off)));
return (alpha_btop(ALPHA_PHYS_TO_K0SEG(CHIP_MEM_SYS_START(v) + addr + off)));
}
radeonfb_mmap(void *v, void *vs, off_t offset, int prot)
{
struct vcons_data *vd;
struct radeonfb_display *dp;
struct radeonfb_softc *sc;
paddr_t pa;
vd = (struct vcons_data *)v;
dp = (struct radeonfb_display *)vd->cookie;
sc = dp->rd_softc;
/* XXX: note that we don't allow mapping of registers right now */
/* XXX: this means that the XFree86 radeon driver won't work */
if ((offset >= 0) && (offset < (dp->rd_virty * dp->rd_stride))) {
pa = bus_space_mmap(sc->sc_memt,
sc->sc_memaddr + dp->rd_offset + offset, 0,
prot, BUS_SPACE_MAP_LINEAR);
printf("rad sc_addr %lx\n",sc->sc_memaddr + dp->rd_offset + offset);
printf("rad pa %lx\n",pa);
panic("radeonfb");
return pa;
}
map addr 40000000
map off 0
map p_k fffffd0440000000
map ret 7ffffe8220000
rad sc_addr 40000000
rad pa 7ffffe8220000
panic: radeonfb
cpu0: Begin traceback...
width 1920 line length 1920 height 1200 depth 8 mmap 0x3fffdc02000 wstype 11
===================================================================================================
pci_genfb_mmap(void *v, void *vs, off_t offset, int prot)
{
struct pci_genfb_softc *sc = v;
struct range *r;
int i;
debug("genfb");
if (offset == 0)
sc->sc_want_wsfb = 1;
/*
* regular fb mapping at 0
* since some Sun firmware likes to put PCI resources low enough
* to collide with the wsfb mapping we only allow it after asking
* for offset 0
*/
DPRINTF("%s: %08x limit %08x\n", __func__, (uint32_t)offset,
(uint32_t)sc->sc_gen.sc_fbsize);
if ((offset >= 0) && (offset < sc->sc_gen.sc_fbsize) &&
(sc->sc_want_wsfb == 1)) {
return bus_space_mmap(sc->sc_memt, sc->sc_gen.sc_fboffset,
offset, prot,
BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE);
}
===================================================================================================
Reading symbols from /netbsd.gdb...done.
#0 0xc05a21e8 in maybe_dump (howto=260)
at /usr/src/sys/arch/i386/i386/machdep.c:878
878 dumpsys();
#0 0xc05a21e8 in maybe_dump (howto=260) at /usr/src/sys/arch/i386/i386/machdep.c:878
#1 cpu_reboot (howto=260, bootstr=0x0) at /usr/src/sys/arch/i386/i386/machdep.c:899
#2 0xc07908ea in vpanic (fmt=0xc0b23fe5 "genfb", ap=0xdb0e5af4 "([\016۩Gx?")
at /usr/src/sys/kern/subr_prf.c:308
#3 0xc079098f in panic (fmt=0xc0b23fe5 "genfb") at /usr/src/sys/kern/subr_prf.c:205
#4 0xc0332342 in pci_genfb_mmap (v=0xc2d85800, vs=0xc2d858c4, offset=0, prot=7)
at /usr/src/sys/dev/pci/genfb_pci.c:247
#5 0xc07847a9 in cdev_mmap (dev=12032, off=0, flag=7) at /usr/src/sys/kern/subr_devsw.c:961
#6 0xc0867fcb in udv_attach (arg=0xc2828954, accessprot=7, off=<optimized out>, size=3145728)
at /usr/src/sys/uvm/uvm_device.c:152
#7 0xc087207a in uvm_mmap (map=0xc3568d88, addr=0xdb0e5cbc, size=3145728, prot=3, maxprot=7, flags=1,
handle=0xc2f492cc, foff=0, locklimit=522943146) at /usr/src/sys/uvm/uvm_mmap.c:1159
#8 0xc0872559 in sys_mmap (l=0xc2f3f800, uap=0xdb0e5d00, retval=0xdb0e5d28)
at /usr/src/sys/uvm/uvm_mmap.c:543
#9 0xc07b1f9a in sy_call (rval=0xdb0e5d28, uap=0xdb0e5d00, l=0xc2f3f800, sy=0xc0c2f4dc)
at /usr/src/sys/sys/syscallvar.h:61
#10 syscall (frame=0xdb0e5d48) at /usr/src/sys/arch/x86/x86/syscall.c:179
#11 0xc010056d in ?? ()
===================================================================================================================
memsetしたときにfaultする
#0 0xc05a2358 in maybe_dump (howto=260)
at /usr/src/sys/arch/i386/i386/machdep.c:878
878 dumpsys();
#0 0xc05a2358 in maybe_dump (howto=260) at /usr/src/sys/arch/i386/i386/machdep.c:878
#1 cpu_reboot (howto=260, bootstr=0x0) at /usr/src/sys/arch/i386/i386/machdep.c:899
#2 0xc0790a5a in vpanic (fmt=0xc0bb1bdb "uvm", ap=0xdb0e5b80 "??0?") at /usr/src/sys/kern/subr_prf.c:308
#3 0xc0790aff in panic (fmt=0xc0bb1bdb "uvm") at /usr/src/sys/kern/subr_prf.c:205
#4 0xc0867db6 in udv_fault (ufi=0xdb0e5c7c, vaddr=3148689408, pps=0xdb0e5bdc, npages=1, centeridx=0,
access_type=2, flags=66) at /usr/src/sys/uvm/uvm_device.c:390
#5 0xc0869130 in uvm_fault_internal (orig_map=0xc357e0e0, vaddr=3148689408, access_type=2, fault_flag=0)
at /usr/src/sys/uvm/uvm_fault.c:897
#6 0xc07de9c2 in trap (frame=0xdb0e5d48) at /usr/src/sys/arch/i386/i386/trap.c:678
#7 0xc010cf48 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
873 /* Disable interrupts. */
874 s = splhigh();
875
876 /* Do a dump if requested. */
877 if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
878 dumpsys();
879
880 splx(s);
881 }
882
eax *value not available*
ecx *value not available*
edx *value not available*
static int
udv_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, struct vm_page **pps,
int npages, int centeridx, vm_prot_t access_type,
int flags)
{
struct vm_map_entry *entry = ufi->entry;
struct uvm_object *uobj = entry->object.uvm_obj;
struct uvm_device *udv = (struct uvm_device *)uobj;
vaddr_t curr_va;
off_t curr_offset;
paddr_t paddr, mdpgno;
u_int mmapflags;
int lcv, retval;
dev_t device;
vm_prot_t mapprot;
UVMHIST_FUNC("udv_fault"); UVMHIST_CALLED(maphist);
UVMHIST_LOG(maphist," flags=%d", flags,0,0,0);
/*
* we do not allow device mappings to be mapped copy-on-write
* so we kill any attempt to do so here.
*/
if (UVM_ET_ISCOPYONWRITE(entry)) {
UVMHIST_LOG(maphist, "<- failed -- COW entry (etype=0x%x)",
entry->etype, 0,0,0);
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, uobj);
return(EIO);
}
/*
* get device map function.
*/
delay(500);
panic("uvm");
device = udv->u_device;
#4 0xc086d850 in uvm_map_findspace (map=0xc358f290, hint=3146776576, length=3145728, result=0xdb41fb10, uobj=0xc2fbab80, uoffset=0,
align=0, flags=5891) at /usr/src/sys/uvm/uvm_map.c:1933
#5 0xc086d919 in uvm_map_prepare (map=0xc358f290, start=3146776576, size=3145728, uobj=0xc2fbab80, uoffset=0, align=0, flags=5891,
args=0xdb41fb3c) at /usr/src/sys/uvm/uvm_map.c:1170
#6 0xc086dac2 in uvm_map (map=0xc358f290, startp=0xdb41fcbc, size=3145728, uobj=0xc2fbab80, uoffset=0, align=0, flags=5891)
at /usr/src/sys/uvm/uvm_map.c:1091
#7 0xc08721d1 in uvm_mmap (map=0xc358f290, addr=0xdb41fcbc, size=3145728, prot=3, maxprot=7, flags=1, handle=0xc2f4a2cc,
foff=<optimized out>, locklimit=522941781) at /usr/src/sys/uvm/uvm_mmap.c:1198
#8 0xc0872759 in sys_mmap (l=0xc35852c0, uap=0xdb41fd00, retval=0xdb41fd28) at /usr/src/sys/uvm/uvm_mmap.c:543
#4 0xc086c6c4 in uvm_map_space_avail (start=0xdb237ac8, length=3145728, align=<optimized out>,
flags=5891, topdown=64, uoffset=<optimized out>, entry=<optimized out>)
at /usr/src/sys/uvm/uvm_map.c:1820
#5 0xc086d437 in uvm_map_findspace (map=0xc34ccbd8, hint=3146776576, length=3145728,
result=0xdb237b10, uobj=0xc2d729c0, uoffset=0, align=0, flags=5891)
at /usr/src/sys/uvm/uvm_map.c:1941
#6 0xc086d8ef in uvm_map_prepare (map=0xc34ccbd8, start=3146776576, size=3145728, uobj=0xc2d729c0,
uoffset=0, align=0, flags=5891, args=0xdb237b3c) at /usr/src/sys/uvm/uvm_map.c:1170
#7 0xc086da98 in uvm_map (map=0xc34ccbd8, startp=0xdb237cbc, size=3145728, uobj=0xc2d729c0, uoffset=0,
align=0, flags=5891) at /usr/src/sys/uvm/uvm_map.c:1091
#8 0xc08721b1 in uvm_mmap (map=0xc34ccbd8, addr=0xdb237cbc, size=3145728, prot=3, maxprot=7, flags=1,
handle=0xc2f4a2cc, foff=<optimized out>, locklimit=522941781) at /usr/src/sys/uvm/uvm_mmap.c:1198
#9 0xc0872739 in sys_mmap (l=0xc2fec2c0, uap=0xdb237d00, retval=0xdb237d28)
at /usr/src/sys/uvm/uvm_mmap.c:543
#10 0xc07b210a in sy_call (rval=0xdb237d28, uap=0xdb237d00, l=0xc2fec2c0, sy=0xc0c2f4dc)
at /usr/src/sys/sys/syscallvar.h:61
#11 syscall (frame=0xdb237d48) at /usr/src/sys/arch/x86/x86/syscall.c:179
#0 0xc05a2358 in maybe_dump (howto=260) at /usr/src/sys/arch/i386/i386/machdep.c:878
#1 cpu_reboot (howto=260, bootstr=0x0) at /usr/src/sys/arch/i386/i386/machdep.c:899
#2 0xc0790a5a in vpanic (fmt=0xc0bb2146 "HITHIT3", ap=0xdb277a98 "") at /usr/src/sys/kern/subr_prf.c:308
#3 0xc0790aff in panic (fmt=0xc0bb2146 "HITHIT3") at /usr/src/sys/kern/subr_prf.c:205
#4 0xc086d1f7 in uvm_map_enter (map=0xc3499950, args=0xdb277b3c, new_entry=0x0) at /usr/src/sys/uvm/uvm_map.c:1537
#5 0xc086db05 in uvm_map (map=0xc3499950, startp=0xdb277cbc, size=3145728, uobj=0xc2f1ac80, uoffset=0, align=0,
flags=<optimized out>) at /usr/src/sys/uvm/uvm_map.c:1094
#6 0xc08721c1 in uvm_mmap (map=0xc3499950, addr=0xdb277cbc, size=3145728, prot=3, maxprot=7, flags=1, handle=0xc2f4a2cc,
foff=<optimized out>, locklimit=522941781) at /usr/src/sys/uvm/uvm_mmap.c:1198
#7 0xc0872749 in sys_mmap (l=0xc2fff2c0, uap=0xdb277d00, retval=0xdb277d28) at /usr/src/sys/uvm/uvm_mmap.c:543
#8 0xc07b210a in sy_call (rval=0xdb277d28, uap=0xdb277d00, l=0xc2fff2c0, sy=0xc0c2f4dc)
at /usr/src/sys/sys/syscallvar.h:61
#9 syscall (frame=0xdb277d48) at /usr/src/sys/arch/x86/x86/syscall.c:179
#10 0xc010056d in ?? ()
sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
...
if (error == 0){
/* remember to add offset */
*retval = (register_t)(addr + pageoff);
}
if (fp != NULL){
fd_putfile(fd);
}
if (size == 3145728){
delay(500);
printf("a %lx\n",(unsigned long)addr);
printf("b %lx\n",(unsigned long)pageoff);
printf("d %x\n",(register_t)(addr + pageoff));
printf("e %p\n",retval);
}
a bb7d4000
b 0
d bb7d4000
e 0xdb275d28
if ((fb = mmap( NULL, line_length * vinfo.height,
PROT_WRITE|PROT_READ, MAP_SHARED, fd , (off_t)0)) == MAP_FAILED) {
fprintf(stderr, "mmap failed.\n");
goto error;
}
fprintf(stderr, "width %d line length %d height %d depth %d mmap %p wstype %d\n" ,
vinfo.width , line_length , vinfo.height , vinfo.depth , fb , wstype);
width 1024 line length 4096 height 768 depth 32 mmap 0xbb7d4000 wstype 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment