machdep.c (1321) | machdep.c (1549) |
---|---|
1/*- 2 * Copyright (c) 1992 Terrence R. Lambert. 3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * William Jolitz. 8 * --- 27 unchanged lines hidden (view full) --- 36 * 37 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 38 * $Id: machdep.c,v 1.41 1994/03/30 02:31:11 davidg Exp $ 39 */ 40 41#include "npx.h" 42#include "isa.h" 43 | 1/*- 2 * Copyright (c) 1992 Terrence R. Lambert. 3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * William Jolitz. 8 * --- 27 unchanged lines hidden (view full) --- 36 * 37 * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 38 * $Id: machdep.c,v 1.41 1994/03/30 02:31:11 davidg Exp $ 39 */ 40 41#include "npx.h" 42#include "isa.h" 43 |
44#include <stddef.h> 45#include "param.h" 46#include "systm.h" 47#include "signalvar.h" 48#include "kernel.h" 49#include "map.h" 50#include "proc.h" 51#include "user.h" 52#include "exec.h" /* for PS_STRINGS */ 53#include "buf.h" 54#include "reboot.h" 55#include "conf.h" 56#include "file.h" 57#include "callout.h" 58#include "malloc.h" 59#include "mbuf.h" 60#include "msgbuf.h" | 44#include <sys/param.h> 45#include <sys/systm.h> 46#include <sys/signalvar.h> 47#include <sys/kernel.h> 48#include <sys/map.h> 49#include <sys/proc.h> 50#include <sys/user.h> 51#include <sys/buf.h> 52#include <sys/reboot.h> 53#include <sys/conf.h> 54#include <sys/file.h> 55#include <sys/callout.h> 56#include <sys/malloc.h> 57#include <sys/mbuf.h> 58#include <sys/msgbuf.h> 59#include <sys/ioctl.h> 60#include <sys/tty.h> 61#include <sys/sysctl.h> |
61 62#ifdef SYSVSHM 63#include "sys/shm.h" 64#endif 65 66#ifdef SYSVMSG 67#include "msg.h" 68#endif --- 20 unchanged lines hidden (view full) --- 89 90#include "i386/isa/isa.h" 91#include "i386/isa/rtc.h" 92 93static void identifycpu(void); 94static void initcpu(void); 95static int test_page(int *, int); 96 | 62 63#ifdef SYSVSHM 64#include "sys/shm.h" 65#endif 66 67#ifdef SYSVMSG 68#include "msg.h" 69#endif --- 20 unchanged lines hidden (view full) --- 90 91#include "i386/isa/isa.h" 92#include "i386/isa/rtc.h" 93 94static void identifycpu(void); 95static void initcpu(void); 96static int test_page(int *, int); 97 |
97extern int grow(struct proc *,int); | 98extern int grow(struct proc *,u_int); |
98const char machine[] = "PC-Class"; 99const char *cpu_model; 100 101#ifndef PANIC_REBOOT_WAIT_TIME 102#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ 103#endif 104 105/* --- 10 unchanged lines hidden (view full) --- 116#else 117int bufpages = 0; 118#endif 119#ifdef BOUNCEPAGES 120int bouncepages = BOUNCEPAGES; 121#else 122int bouncepages = 0; 123#endif | 99const char machine[] = "PC-Class"; 100const char *cpu_model; 101 102#ifndef PANIC_REBOOT_WAIT_TIME 103#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ 104#endif 105 106/* --- 10 unchanged lines hidden (view full) --- 117#else 118int bufpages = 0; 119#endif 120#ifdef BOUNCEPAGES 121int bouncepages = BOUNCEPAGES; 122#else 123int bouncepages = 0; 124#endif |
125int msgbufmapped = 0; /* set when safe to use msgbuf */ |
|
124extern int freebufspace; 125extern char *bouncememory; 126 127int _udatasel, _ucodesel; 128 129/* 130 * Machine-dependent startup code 131 */ --- 4 unchanged lines hidden (view full) --- 136 137vm_offset_t phys_avail[6]; 138 139extern cyloffset; 140 141int cpu_class; 142 143void dumpsys __P((void)); | 126extern int freebufspace; 127extern char *bouncememory; 128 129int _udatasel, _ucodesel; 130 131/* 132 * Machine-dependent startup code 133 */ --- 4 unchanged lines hidden (view full) --- 138 139vm_offset_t phys_avail[6]; 140 141extern cyloffset; 142 143int cpu_class; 144 145void dumpsys __P((void)); |
146vm_offset_t buffer_sva, buffer_eva; 147vm_offset_t clean_sva, clean_eva; 148vm_offset_t pager_sva, pager_eva; 149int maxbkva, pager_map_size; |
|
144 | 150 |
151#define offsetof(type, member) ((size_t)(&((type *)0)->member)) 152 |
|
145void 146cpu_startup() 147{ 148 register int unixsize; 149 register unsigned i; 150 register struct pte *pte; 151 int mapaddr, j; 152 register caddr_t v; --- 117 unchanged lines hidden (view full) --- 270 } 271 272 /* 273 * End of second pass, addresses have been assigned 274 */ 275 if ((vm_size_t)(v - firstaddr) != size) 276 panic("startup: table size inconsistency"); 277 | 153void 154cpu_startup() 155{ 156 register int unixsize; 157 register unsigned i; 158 register struct pte *pte; 159 int mapaddr, j; 160 register caddr_t v; --- 117 unchanged lines hidden (view full) --- 278 } 279 280 /* 281 * End of second pass, addresses have been assigned 282 */ 283 if ((vm_size_t)(v - firstaddr) != size) 284 panic("startup: table size inconsistency"); 285 |
286 clean_map = kmem_suballoc(kernel_map, &clean_sva, &clean_eva, 287 (nbuf*MAXBSIZE) + VM_PHYS_SIZE + maxbkva + pager_map_size, TRUE); 288 289 io_map = kmem_suballoc(clean_map, &minaddr, &maxaddr, maxbkva, FALSE); 290 pager_map = kmem_suballoc(clean_map, &pager_sva, &pager_eva, 291 pager_map_size, TRUE); 292 293 buffer_map = kmem_suballoc(clean_map, &buffer_sva, &buffer_eva, 294 (nbuf * MAXBSIZE), TRUE); |
|
278 /* | 295 /* |
279 * Allocate a submap for buffer space allocations. 280 * XXX we are NOT using buffer_map, but due to 281 * the references to it we will just allocate 1 page of 282 * vm (not real memory) to make things happy... 283 */ 284 buffer_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, 285 /* bufpages * */NBPG, TRUE); 286 /* | |
287 * Allocate a submap for physio 288 */ | 296 * Allocate a submap for physio 297 */ |
289 phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, | 298 phys_map = kmem_suballoc(clean_map, &minaddr, &maxaddr, |
290 VM_PHYS_SIZE, TRUE); 291 292 /* 293 * Finally, allocate mbuf pool. Since mclrefcnt is an off-size 294 * we use the more space efficient malloc in place of kmem_alloc. 295 */ 296 mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES, 297 M_MBUF, M_NOWAIT); 298 bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES); | 299 VM_PHYS_SIZE, TRUE); 300 301 /* 302 * Finally, allocate mbuf pool. Since mclrefcnt is an off-size 303 * we use the more space efficient malloc in place of kmem_alloc. 304 */ 305 mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES, 306 M_MBUF, M_NOWAIT); 307 bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES); |
299 mb_map = kmem_suballoc(kmem_map, (vm_offset_t)&mbutl, &maxaddr, | 308 mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr, |
300 VM_MBUF_SIZE, FALSE); 301 /* 302 * Initialize callouts 303 */ 304 callfree = callout; 305 for (i = 1; i < ncallout; i++) 306 callout[i-1].c_next = &callout[i]; 307 | 309 VM_MBUF_SIZE, FALSE); 310 /* 311 * Initialize callouts 312 */ 313 callfree = callout; 314 for (i = 1; i < ncallout; i++) 315 callout[i-1].c_next = &callout[i]; 316 |
308 printf("avail memory = %d (%d pages)\n", ptoa(vm_page_free_count), vm_page_free_count); | 317 printf("avail memory = %d (%d pages)\n", ptoa(cnt.v_free_count), cnt.v_free_count); |
309 printf("using %d buffers containing %d bytes of memory\n", 310 nbuf, bufpages * CLBYTES); 311 312#ifndef NOBOUNCE 313 /* 314 * init bounce buffers 315 */ 316 vm_bounce_init(); --- 115 unchanged lines hidden (view full) --- 432sendsig(catcher, sig, mask, code) 433 sig_t catcher; 434 int sig, mask; 435 unsigned code; 436{ 437 register struct proc *p = curproc; 438 register int *regs; 439 register struct sigframe *fp; | 318 printf("using %d buffers containing %d bytes of memory\n", 319 nbuf, bufpages * CLBYTES); 320 321#ifndef NOBOUNCE 322 /* 323 * init bounce buffers 324 */ 325 vm_bounce_init(); --- 115 unchanged lines hidden (view full) --- 441sendsig(catcher, sig, mask, code) 442 sig_t catcher; 443 int sig, mask; 444 unsigned code; 445{ 446 register struct proc *p = curproc; 447 register int *regs; 448 register struct sigframe *fp; |
440 struct sigacts *ps = p->p_sigacts; | 449 struct sigacts *psp = p->p_sigacts; |
441 int oonstack, frmtrap; 442 | 450 int oonstack, frmtrap; 451 |
443 regs = p->p_regs; 444 oonstack = ps->ps_onstack; | 452 regs = p->p_md.md_regs; 453 oonstack = psp->ps_sigstk.ss_flags & SA_ONSTACK; |
445 /* 446 * Allocate and validate space for the signal handler 447 * context. Note that if the stack is in P0 space, the 448 * call to grow() is a nop, and the useracc() check 449 * will fail if the process has not already allocated 450 * the space with a `brk'. 451 */ | 454 /* 455 * Allocate and validate space for the signal handler 456 * context. Note that if the stack is in P0 space, the 457 * call to grow() is a nop, and the useracc() check 458 * will fail if the process has not already allocated 459 * the space with a `brk'. 460 */ |
452 if (!ps->ps_onstack && (ps->ps_sigonstack & sigmask(sig))) { 453 fp = (struct sigframe *)(ps->ps_sigsp 454 - sizeof(struct sigframe)); 455 ps->ps_onstack = 1; | 461 if ((psp->ps_flags & SAS_ALTSTACK) && 462 (psp->ps_sigstk.ss_flags & SA_ONSTACK) == 0 && 463 (psp->ps_sigonstack & sigmask(sig))) { 464 fp = (struct sigframe *)(psp->ps_sigstk.ss_base + 465 psp->ps_sigstk.ss_size - sizeof(struct sigframe)); 466 psp->ps_sigstk.ss_flags |= SA_ONSTACK; |
456 } else { 457 fp = (struct sigframe *)(regs[tESP] 458 - sizeof(struct sigframe)); 459 } 460 461 /* 462 * grow() will return FALSE if the fp will not fit inside the stack 463 * and the stack can not be grown. useracc will return FALSE --- 71 unchanged lines hidden (view full) --- 535int 536sigreturn(p, uap, retval) 537 struct proc *p; 538 struct sigreturn_args *uap; 539 int *retval; 540{ 541 register struct sigcontext *scp; 542 register struct sigframe *fp; | 467 } else { 468 fp = (struct sigframe *)(regs[tESP] 469 - sizeof(struct sigframe)); 470 } 471 472 /* 473 * grow() will return FALSE if the fp will not fit inside the stack 474 * and the stack can not be grown. useracc will return FALSE --- 71 unchanged lines hidden (view full) --- 546int 547sigreturn(p, uap, retval) 548 struct proc *p; 549 struct sigreturn_args *uap; 550 int *retval; 551{ 552 register struct sigcontext *scp; 553 register struct sigframe *fp; |
543 register int *regs = p->p_regs; | 554 register int *regs = p->p_md.md_regs; |
544 int eflags; 545 546 /* 547 * (XXX old comment) regs[tESP] points to the return address. 548 * The user scp pointer is above that. 549 * The return address is faked in the signal trampoline code 550 * for consistency. 551 */ --- 57 unchanged lines hidden (view full) --- 609 regs[tDS] = scp->sc_ds; 610 regs[tES] = scp->sc_es; 611 regs[tSS] = scp->sc_ss; 612 regs[tISP] = scp->sc_isp; 613 614 if (useracc((caddr_t)scp, sizeof (*scp), 0) == 0) 615 return(EINVAL); 616 | 555 int eflags; 556 557 /* 558 * (XXX old comment) regs[tESP] points to the return address. 559 * The user scp pointer is above that. 560 * The return address is faked in the signal trampoline code 561 * for consistency. 562 */ --- 57 unchanged lines hidden (view full) --- 620 regs[tDS] = scp->sc_ds; 621 regs[tES] = scp->sc_es; 622 regs[tSS] = scp->sc_ss; 623 regs[tISP] = scp->sc_isp; 624 625 if (useracc((caddr_t)scp, sizeof (*scp), 0) == 0) 626 return(EINVAL); 627 |
617 p->p_sigacts->ps_onstack = scp->sc_onstack & 01; | 628 if (scp->sc_onstack & 01) 629 p->p_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK; 630 else 631 p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK; |
618 p->p_sigmask = scp->sc_mask &~ 619 (sigmask(SIGKILL)|sigmask(SIGCONT)|sigmask(SIGSTOP)); 620 regs[tEBP] = scp->sc_fp; 621 regs[tESP] = scp->sc_sp; 622 regs[tEIP] = scp->sc_pc; 623 regs[tEFLAGS] = eflags; 624 return(EJUSTRETURN); 625} --- 20 unchanged lines hidden (view full) --- 646 extern int cold; 647 int nomsg = 1; 648 649 if (cold) { 650 printf("hit reset please"); 651 for(;;); 652 } 653 howto = arghowto; | 632 p->p_sigmask = scp->sc_mask &~ 633 (sigmask(SIGKILL)|sigmask(SIGCONT)|sigmask(SIGSTOP)); 634 regs[tEBP] = scp->sc_fp; 635 regs[tESP] = scp->sc_sp; 636 regs[tEIP] = scp->sc_pc; 637 regs[tEFLAGS] = eflags; 638 return(EJUSTRETURN); 639} --- 20 unchanged lines hidden (view full) --- 660 extern int cold; 661 int nomsg = 1; 662 663 if (cold) { 664 printf("hit reset please"); 665 for(;;); 666 } 667 howto = arghowto; |
654 if ((howto&RB_NOSYNC) == 0 && waittime < 0 && bfreelist[0].b_forw) { | 668 if ((howto&RB_NOSYNC) == 0 && waittime < 0) { |
655 register struct buf *bp; 656 int iter, nbusy; 657 658 waittime = 0; 659 (void) splnet(); 660 printf("syncing disks... "); 661 /* 662 * Release inodes held by texts before update. --- 150 unchanged lines hidden (view full) --- 813 * Clear registers on exec 814 */ 815void 816setregs(p, entry, stack) 817 struct proc *p; 818 u_long entry; 819 u_long stack; 820{ | 669 register struct buf *bp; 670 int iter, nbusy; 671 672 waittime = 0; 673 (void) splnet(); 674 printf("syncing disks... "); 675 /* 676 * Release inodes held by texts before update. --- 150 unchanged lines hidden (view full) --- 827 * Clear registers on exec 828 */ 829void 830setregs(p, entry, stack) 831 struct proc *p; 832 u_long entry; 833 u_long stack; 834{ |
821 p->p_regs[tEBP] = 0; /* bottom of the fp chain */ 822 p->p_regs[tEIP] = entry; 823 p->p_regs[tESP] = stack; 824 p->p_regs[tSS] = _udatasel; 825 p->p_regs[tDS] = _udatasel; 826 p->p_regs[tES] = _udatasel; 827 p->p_regs[tCS] = _ucodesel; | 835 p->p_md.md_regs[tEBP] = 0; /* bottom of the fp chain */ 836 p->p_md.md_regs[tEIP] = entry; 837 p->p_md.md_regs[tESP] = stack; 838 p->p_md.md_regs[tSS] = _udatasel; 839 p->p_md.md_regs[tDS] = _udatasel; 840 p->p_md.md_regs[tES] = _udatasel; 841 p->p_md.md_regs[tCS] = _ucodesel; |
828 829 p->p_addr->u_pcb.pcb_flags = 0; /* no fp at all */ 830 load_cr0(rcr0() | CR0_TS); /* start emulating */ 831#if NNPX > 0 832 npxinit(__INITIAL_NPXCW__); 833#endif /* NNPX > 0 */ 834} 835 836/* | 842 843 p->p_addr->u_pcb.pcb_flags = 0; /* no fp at all */ 844 load_cr0(rcr0() | CR0_TS); /* start emulating */ 845#if NNPX > 0 846 npxinit(__INITIAL_NPXCW__); 847#endif /* NNPX > 0 */ 848} 849 850/* |
851 * machine dependent system variables. 852 */ 853int 854cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) 855 int *name; 856 u_int namelen; 857 void *oldp; 858 size_t *oldlenp; 859 void *newp; 860 size_t newlen; 861 struct proc *p; 862{ 863 864 /* all sysctl names at this level are terminal */ 865 if (namelen != 1) 866 return (ENOTDIR); /* overloaded */ 867 868 switch (name[0]) { 869 case CPU_CONSDEV: 870 return (sysctl_rdstruct(oldp, oldlenp, newp, &cn_tty->t_dev, 871 sizeof cn_tty->t_dev)); 872 default: 873 return (EOPNOTSUPP); 874 } 875 /* NOTREACHED */ 876} 877 878/* |
|
837 * Initialize 386 and configure to run kernel 838 */ 839 840/* 841 * Initialize segments & interrupt table 842 */ 843 844union descriptor gdt[NGDT]; --- 255 unchanged lines hidden (view full) --- 1100#include "isa.h" 1101#if NISA >0 1102 isa_defaultirq(); 1103#endif 1104 1105 r_gdt.rd_limit = sizeof(gdt) - 1; 1106 r_gdt.rd_base = (int) gdt; 1107 lgdt(&r_gdt); | 879 * Initialize 386 and configure to run kernel 880 */ 881 882/* 883 * Initialize segments & interrupt table 884 */ 885 886union descriptor gdt[NGDT]; --- 255 unchanged lines hidden (view full) --- 1142#include "isa.h" 1143#if NISA >0 1144 isa_defaultirq(); 1145#endif 1146 1147 r_gdt.rd_limit = sizeof(gdt) - 1; 1148 r_gdt.rd_base = (int) gdt; 1149 lgdt(&r_gdt); |
1150 |
|
1108 r_idt.rd_limit = sizeof(idt) - 1; 1109 r_idt.rd_base = (int) idt; 1110 lidt(&r_idt); | 1151 r_idt.rd_limit = sizeof(idt) - 1; 1152 r_idt.rd_base = (int) idt; 1153 lidt(&r_idt); |
1154 |
|
1111 _default_ldt = GSEL(GLDT_SEL, SEL_KPL); 1112 lldt(_default_ldt); 1113 currentldt = _default_ldt; 1114 1115#include "ddb.h" 1116#if NDDB > 0 1117 kdb_init(); 1118 if (boothowto & RB_KDB) --- 215 unchanged lines hidden (view full) --- 1334 ((struct prochd *)(element->ph_rlink))->ph_link = element->ph_link; 1335 element->ph_rlink = (struct proc *)0; 1336} 1337 1338/* 1339 * The registers are in the frame; the frame is in the user area of 1340 * the process in question; when the process is active, the registers 1341 * are in "the kernel stack"; when it's not, they're still there, but | 1155 _default_ldt = GSEL(GLDT_SEL, SEL_KPL); 1156 lldt(_default_ldt); 1157 currentldt = _default_ldt; 1158 1159#include "ddb.h" 1160#if NDDB > 0 1161 kdb_init(); 1162 if (boothowto & RB_KDB) --- 215 unchanged lines hidden (view full) --- 1378 ((struct prochd *)(element->ph_rlink))->ph_link = element->ph_link; 1379 element->ph_rlink = (struct proc *)0; 1380} 1381 1382/* 1383 * The registers are in the frame; the frame is in the user area of 1384 * the process in question; when the process is active, the registers 1385 * are in "the kernel stack"; when it's not, they're still there, but |
1342 * things get flipped around. So, since p->p_regs is the whole address | 1386 * things get flipped around. So, since p->p_md.md_regs is the whole address |
1343 * of the register set, take its offset from the kernel stack, and 1344 * index into the user block. Don't you just *love* virtual memory? 1345 * (I'm starting to think seymour is right...) 1346 */ 1347 1348int 1349ptrace_set_pc (struct proc *p, unsigned int addr) { 1350 void *regs = (char*)p->p_addr + | 1387 * of the register set, take its offset from the kernel stack, and 1388 * index into the user block. Don't you just *love* virtual memory? 1389 * (I'm starting to think seymour is right...) 1390 */ 1391 1392int 1393ptrace_set_pc (struct proc *p, unsigned int addr) { 1394 void *regs = (char*)p->p_addr + |
1351 ((char*) p->p_regs - (char*) kstack); | 1395 ((char*) p->p_md.md_regs - (char*) kstack); |
1352 1353 ((struct trapframe *)regs)->tf_eip = addr; 1354 return 0; 1355} 1356 1357int 1358ptrace_single_step (struct proc *p) { 1359 void *regs = (char*)p->p_addr + | 1396 1397 ((struct trapframe *)regs)->tf_eip = addr; 1398 return 0; 1399} 1400 1401int 1402ptrace_single_step (struct proc *p) { 1403 void *regs = (char*)p->p_addr + |
1360 ((char*) p->p_regs - (char*) kstack); | 1404 ((char*) p->p_md.md_regs - (char*) kstack); |
1361 1362 ((struct trapframe *)regs)->tf_eflags |= PSL_T; 1363 return 0; 1364} 1365 1366/* 1367 * Copy the registers to user-space. 1368 */ 1369 1370int 1371ptrace_getregs (struct proc *p, unsigned int *addr) { 1372 int error; | 1405 1406 ((struct trapframe *)regs)->tf_eflags |= PSL_T; 1407 return 0; 1408} 1409 1410/* 1411 * Copy the registers to user-space. 1412 */ 1413 1414int 1415ptrace_getregs (struct proc *p, unsigned int *addr) { 1416 int error; |
1373 struct regs regs = {0}; | 1417 struct reg regs = {0}; |
1374 1375 if (error = fill_regs (p, ®s)) 1376 return error; 1377 1378 return copyout (®s, addr, sizeof (regs)); 1379} 1380 1381int 1382ptrace_setregs (struct proc *p, unsigned int *addr) { 1383 int error; | 1418 1419 if (error = fill_regs (p, ®s)) 1420 return error; 1421 1422 return copyout (®s, addr, sizeof (regs)); 1423} 1424 1425int 1426ptrace_setregs (struct proc *p, unsigned int *addr) { 1427 int error; |
1384 struct regs regs = {0}; | 1428 struct reg regs = {0}; |
1385 1386 if (error = copyin (addr, ®s, sizeof(regs))) 1387 return error; 1388 1389 return set_regs (p, ®s); 1390} 1391 1392int | 1429 1430 if (error = copyin (addr, ®s, sizeof(regs))) 1431 return error; 1432 1433 return set_regs (p, ®s); 1434} 1435 1436int |
1393fill_regs(struct proc *p, struct regs *regs) { | 1437fill_regs(struct proc *p, struct reg *regs) { |
1394 int error; 1395 struct trapframe *tp; 1396 void *ptr = (char*)p->p_addr + | 1438 int error; 1439 struct trapframe *tp; 1440 void *ptr = (char*)p->p_addr + |
1397 ((char*) p->p_regs - (char*) kstack); | 1441 ((char*) p->p_md.md_regs - (char*) kstack); |
1398 1399 tp = ptr; 1400 regs->r_es = tp->tf_es; 1401 regs->r_ds = tp->tf_ds; 1402 regs->r_edi = tp->tf_edi; 1403 regs->r_esi = tp->tf_esi; 1404 regs->r_ebp = tp->tf_ebp; 1405 regs->r_ebx = tp->tf_ebx; --- 4 unchanged lines hidden (view full) --- 1410 regs->r_cs = tp->tf_cs; 1411 regs->r_eflags = tp->tf_eflags; 1412 regs->r_esp = tp->tf_esp; 1413 regs->r_ss = tp->tf_ss; 1414 return 0; 1415} 1416 1417int | 1442 1443 tp = ptr; 1444 regs->r_es = tp->tf_es; 1445 regs->r_ds = tp->tf_ds; 1446 regs->r_edi = tp->tf_edi; 1447 regs->r_esi = tp->tf_esi; 1448 regs->r_ebp = tp->tf_ebp; 1449 regs->r_ebx = tp->tf_ebx; --- 4 unchanged lines hidden (view full) --- 1454 regs->r_cs = tp->tf_cs; 1455 regs->r_eflags = tp->tf_eflags; 1456 regs->r_esp = tp->tf_esp; 1457 regs->r_ss = tp->tf_ss; 1458 return 0; 1459} 1460 1461int |
1418set_regs (struct proc *p, struct regs *regs) { | 1462set_regs (struct proc *p, struct reg *regs) { |
1419 int error; 1420 struct trapframe *tp; 1421 void *ptr = (char*)p->p_addr + | 1463 int error; 1464 struct trapframe *tp; 1465 void *ptr = (char*)p->p_addr + |
1422 ((char*) p->p_regs - (char*) kstack); | 1466 ((char*) p->p_md.md_regs - (char*) kstack); |
1423 1424 tp = ptr; 1425 tp->tf_es = regs->r_es; 1426 tp->tf_ds = regs->r_ds; 1427 tp->tf_edi = regs->r_edi; 1428 tp->tf_esi = regs->r_esi; 1429 tp->tf_ebp = regs->r_ebp; 1430 tp->tf_ebx = regs->r_ebx; --- 8 unchanged lines hidden (view full) --- 1439 return 0; 1440} 1441 1442#include "ddb.h" 1443#if NDDB <= 0 1444void 1445Debugger(const char *msg) 1446{ | 1467 1468 tp = ptr; 1469 tp->tf_es = regs->r_es; 1470 tp->tf_ds = regs->r_ds; 1471 tp->tf_edi = regs->r_edi; 1472 tp->tf_esi = regs->r_esi; 1473 tp->tf_ebp = regs->r_ebp; 1474 tp->tf_ebx = regs->r_ebx; --- 8 unchanged lines hidden (view full) --- 1483 return 0; 1484} 1485 1486#include "ddb.h" 1487#if NDDB <= 0 1488void 1489Debugger(const char *msg) 1490{ |
1447 printf("Debugger(\"%s\") called.", msg); | 1491 printf("Debugger(\"%s\") called.\n", msg); |
1448} 1449#endif /* no DDB */ | 1492} 1493#endif /* no DDB */ |
1494 1495#include <sys/disklabel.h> 1496#define b_cylin b_resid 1497#define dkpart(dev) (minor(dev) & 7) 1498/* 1499 * Determine the size of the transfer, and make sure it is 1500 * within the boundaries of the partition. Adjust transfer 1501 * if needed, and signal errors or early completion. 1502 */ 1503int 1504bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) 1505{ 1506 struct partition *p = lp->d_partitions + dkpart(bp->b_dev); 1507 int labelsect = lp->d_partitions[0].p_offset; 1508 int maxsz = p->p_size, 1509 sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT; 1510 1511 /* overwriting disk label ? */ 1512 /* XXX should also protect bootstrap in first 8K */ 1513 if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsect && 1514#if LABELSECTOR != 0 1515 bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && 1516#endif 1517 (bp->b_flags & B_READ) == 0 && wlabel == 0) { 1518 bp->b_error = EROFS; 1519 goto bad; 1520 } 1521 1522#if defined(DOSBBSECTOR) && defined(notyet) 1523 /* overwriting master boot record? */ 1524 if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && 1525 (bp->b_flags & B_READ) == 0 && wlabel == 0) { 1526 bp->b_error = EROFS; 1527 goto bad; 1528 } 1529#endif 1530 1531 /* beyond partition? */ 1532 if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) { 1533 /* if exactly at end of disk, return an EOF */ 1534 if (bp->b_blkno == maxsz) { 1535 bp->b_resid = bp->b_bcount; 1536 return(0); 1537 } 1538 /* or truncate if part of it fits */ 1539 sz = maxsz - bp->b_blkno; 1540 if (sz <= 0) { 1541 bp->b_error = EINVAL; 1542 goto bad; 1543 } 1544 bp->b_bcount = sz << DEV_BSHIFT; 1545 } 1546 1547 /* calculate cylinder for disksort to order transfers with */ 1548 bp->b_pblkno = bp->b_blkno + p->p_offset; 1549 bp->b_cylin = bp->b_pblkno / lp->d_secpercyl; 1550 return(1); 1551 1552bad: 1553 bp->b_flags |= B_ERROR; 1554 return(-1); 1555} 1556 |
|