home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / bsd / 11925 < prev    next >
Encoding:
Text File  |  1993-01-28  |  25.4 KB  |  1,296 lines

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!udel!darwin.sura.net!newsserver.jvnc.net!gmd.de!Germany.EU.net!mcsun!sunic!chalmers.se!cs.chalmers.se!augustss
  2. From: augustss@cs.chalmers.se (Lennart Augustsson)
  3. Newsgroups: comp.unix.bsd
  4. Subject: Big kernel speedup
  5. Message-ID: <1993Jan27.153106.2174@cs.chalmers.se>
  6. Date: 27 Jan 93 15:31:06 GMT
  7. Sender: news@cs.chalmers.se (News administrator)
  8. Organization: Dept. of CS, Chalmers, Sweden
  9. Lines: 1285
  10.  
  11.  
  12. Here are some patches that on my system (a noname 33Mhz 486) just
  13. about *halves* the system time (at least for recompiling the kernel).
  14. It also enables profiling of the assembly language routines in
  15. locore.s and icu.s.
  16.  
  17. The patch does a few things:
  18.  - if you put the NONOP option in your system configuration file
  19.    the NOP and NOP1 macros will be empty.  These two macros
  20.    are used to introduce delays for certain operations.
  21.    On my machine these delays are not necessary.  I suggest that 
  22.    you try with the NONOP option, but be careful.  Bad I/O timing
  23.    can wreak havoc.  The best is to try this from a floppy first.
  24.    If you can use the NONOP option this is a big save.
  25.  - The old spl routines manipulated the ICU as soon as they
  26.    were called.  The new ones check if what they are about to
  27.    write to the ICU is the same as the old interrupt mask
  28.    (quite common) and skips the out instruction if it is.
  29.    This saves a bit since I/O can be very slow.
  30.  - Unrelated to performance, but important for profiling the
  31.    kernel, most assembly routines now call mcount if the system
  32.    is compiled with profiling.  There are some new spl routines
  33.    that do not call mcount (called nmsplXXX); they are needed
  34.    in the profiling code itself.
  35.  
  36. I've been running with these fixes installed for several
  37. months now without any problems.
  38.  
  39. The patch should be applied to a system where the patches in 
  40. patchkit version 0.2 have already been applied.
  41.  
  42.     Good luck
  43.     -- Lennart Augustsson
  44.  
  45.  
  46. *** ./kern/subr_mcount.c.pre    Mon Jan 25 23:31:58 1993
  47. --- ./kern/subr_mcount.c    Mon Jan 25 23:32:23 1993
  48. ***************
  49. *** 185,191 ****
  50.       asm("movw    sr,%0" : "=g" (s));
  51.       asm("movw    #0x2700,sr");
  52.   #else
  53. !     s = splhigh();
  54.   #endif
  55.       /*
  56.        * Check that frompcindex is a reasonable pc value.
  57. --- 185,191 ----
  58.       asm("movw    sr,%0" : "=g" (s));
  59.       asm("movw    #0x2700,sr");
  60.   #else
  61. !     s = nmsplhigh();
  62.   #endif
  63.       /*
  64.        * Check that frompcindex is a reasonable pc value.
  65. ***************
  66. *** 267,273 ****
  67.   #if defined(hp300)
  68.       asm("movw    %0,sr" : : "g" (s));
  69.   #else
  70. !     splx(s);
  71.   #endif
  72.       /* and fall through */
  73.   out:
  74. --- 267,273 ----
  75.   #if defined(hp300)
  76.       asm("movw    %0,sr" : : "g" (s));
  77.   #else
  78. !     nmsplx(s);
  79.   #endif
  80.       /* and fall through */
  81.   out:
  82. *** ./i386/i386/locore.s.pre    Sun Jan 24 22:58:29 1993
  83. --- ./i386/i386/locore.s    Wed Jan 27 02:13:42 1993
  84. ***************
  85. *** 60,65 ****
  86. --- 60,77 ----
  87.   
  88.   #include "machine/trap.h"
  89.   
  90. + #ifdef GPROF
  91. + #define    CENTRY(x)    .globl _/**/x; \
  92. +             .data; 1:; .long 0; .text; .align 2; _/**/x: \
  93. +             movl $1b,%eax; call mcount 
  94. + #define    CENTRY2(x,y)    .globl _/**/x; .globl _/**/y; \
  95. +             .data; 1:; .long 0; .text; .align 2; _/**/x: ; _/**/y: \
  96. +             movl $1b,%eax; call mcount
  97. + #else /* GPROF */
  98. + #define    CENTRY(x)    .globl _/**/x; .text; .align 2; _/**/x:
  99. + #define    CENTRY2(x,y)    .globl _/**/x; .globl _/**/y; .text; .align 2; _/**/x: ; _/**/y:
  100. + #endif /* GPROF */
  101.   /*
  102.    * Note: This version greatly munged to avoid various assembler errors
  103.    * that may be fixed in newer versions of gas. Perhaps newer versions
  104. ***************
  105. *** 71,77 ****
  106. --- 83,97 ----
  107.       /*note: gas copys sign bit (e.g. arithmetic >>), can't do SYSTEM>>22! */
  108.       .set    SYSPDROFF,0x3F8        # Page dir index of System Base
  109.   
  110. + /* Some machines do not require nops.  A big speedup! */
  111. + #if defined(NONOP)
  112. + #define NOP    ;
  113. + #define NOP1    ;
  114. + #else
  115.   #define    NOP    inb $0x84, %al ; inb $0x84, %al 
  116. + #define NOP1    inb $0x84,%al
  117. + #endif
  118.   #define    ALIGN32    .align 2    /* 2^2  = 4 */
  119.   
  120.   /*
  121. ***************
  122. *** 105,114 ****
  123. --- 125,136 ----
  124.       .set    PPDROFF,0x3F6
  125.       .set    PPTEOFF,0x400-UPAGES    # 0x3FE
  126.   
  127. + #if 0
  128.   #define    ENTRY(name) \
  129.       .globl _/**/name; _/**/name:
  130.   #define    ALTENTRY(name) \
  131.       .globl _/**/name; _/**/name:
  132. + #endif
  133.   
  134.   /*
  135.    * Initialization
  136. ***************
  137. *** 401,409 ****
  138.       /*
  139.        * I/O bus instructions via C
  140.        */
  141. !     .globl    _inb
  142. !     ALIGN32
  143. ! _inb:    movl    4(%esp),%edx
  144.       subl    %eax,%eax    # clr eax
  145.       NOP
  146.       inb    %dx,%al
  147. --- 423,430 ----
  148.       /*
  149.        * I/O bus instructions via C
  150.        */
  151. ! CENTRY(inb)
  152. !     movl    4(%esp),%edx
  153.       subl    %eax,%eax    # clr eax
  154.       NOP
  155.       inb    %dx,%al
  156. ***************
  157. *** 410,418 ****
  158.       ret
  159.   
  160.   
  161. !     .globl    _inw
  162. !     ALIGN32
  163. ! _inw:    movl    4(%esp),%edx
  164.       subl    %eax,%eax    # clr eax
  165.       NOP
  166.       inw    %dx,%ax
  167. --- 431,438 ----
  168.       ret
  169.   
  170.   
  171. ! CENTRY(inw)
  172. !     movl    4(%esp),%edx
  173.       subl    %eax,%eax    # clr eax
  174.       NOP
  175.       inw    %dx,%ax
  176. ***************
  177. *** 419,435 ****
  178.       ret
  179.   
  180.   
  181. !     .globl    _rtcin
  182. !     ALIGN32
  183. ! _rtcin:    movl    4(%esp),%eax
  184.       outb    %al,$0x70
  185.       subl    %eax,%eax    # clr eax
  186.       inb    $0x71,%al    # Compaq SystemPro 
  187.       ret
  188.   
  189. !     .globl    _outb
  190. !     ALIGN32
  191. ! _outb:    movl    4(%esp),%edx
  192.       NOP
  193.       movl    8(%esp),%eax
  194.       outb    %al,%dx
  195. --- 439,453 ----
  196.       ret
  197.   
  198.   
  199. ! CENTRY(rtcin)
  200. !     movl    4(%esp),%eax
  201.       outb    %al,$0x70
  202.       subl    %eax,%eax    # clr eax
  203.       inb    $0x71,%al    # Compaq SystemPro 
  204.       ret
  205.   
  206. ! CENTRY(outb)
  207. !     movl    4(%esp),%edx
  208.       NOP
  209.       movl    8(%esp),%eax
  210.       outb    %al,%dx
  211. ***************
  212. *** 436,444 ****
  213.       NOP
  214.       ret
  215.   
  216. !     .globl    _outw
  217. !     ALIGN32
  218. ! _outw:    movl    4(%esp),%edx
  219.       NOP
  220.       movl    8(%esp),%eax
  221.       outw    %ax,%dx
  222. --- 454,461 ----
  223.       NOP
  224.       ret
  225.   
  226. ! CENTRY(outw)
  227. !     movl    4(%esp),%edx
  228.       NOP
  229.       movl    8(%esp),%eax
  230.       outw    %ax,%dx
  231. ***************
  232. *** 449,457 ****
  233.        * void bzero(void *base, u_int cnt)
  234.        */
  235.   
  236. !     .globl _bzero
  237. !     ALIGN32
  238. ! _bzero:
  239.       pushl    %edi
  240.       movl    8(%esp),%edi
  241.       movl    12(%esp),%ecx
  242. --- 466,472 ----
  243.        * void bzero(void *base, u_int cnt)
  244.        */
  245.   
  246. ! CENTRY(bzero)
  247.       pushl    %edi
  248.       movl    8(%esp),%edi
  249.       movl    12(%esp),%ecx
  250. ***************
  251. *** 471,479 ****
  252.        * fillw (pat,base,cnt)
  253.        */
  254.   
  255. !     .globl _fillw
  256. !     ALIGN32
  257. ! _fillw:
  258.       pushl    %edi
  259.       movl    8(%esp),%eax
  260.       movl    12(%esp),%edi
  261. --- 486,492 ----
  262.        * fillw (pat,base,cnt)
  263.        */
  264.   
  265. ! CENTRY(fillw)
  266.       pushl    %edi
  267.       movl    8(%esp),%eax
  268.       movl    12(%esp),%edi
  269. ***************
  270. *** 484,492 ****
  271.       popl    %edi
  272.       ret
  273.   
  274. !     .globl _bcopyb
  275. !     ALIGN32
  276. ! _bcopyb:
  277.       pushl    %esi
  278.       pushl    %edi
  279.       movl    12(%esp),%esi
  280. --- 497,503 ----
  281.       popl    %edi
  282.       ret
  283.   
  284. ! CENTRY(bcopyb)
  285.       pushl    %esi
  286.       pushl    %edi
  287.       movl    12(%esp),%esi
  288. ***************
  289. *** 505,514 ****
  290.        *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
  291.        */
  292.   
  293. !     .globl    _bcopy,_ovbcopy
  294. !     ALIGN32
  295. ! _ovbcopy:
  296. ! _bcopy:
  297.       pushl    %esi
  298.       pushl    %edi
  299.       movl    12(%esp),%esi
  300. --- 516,523 ----
  301.        *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
  302.        */
  303.   
  304. ! CENTRY2(ovbcopy,bcopy)
  305.       pushl    %esi
  306.       pushl    %edi
  307.       movl    12(%esp),%esi
  308. ***************
  309. *** 551,559 ****
  310.       ret
  311.   
  312.   #ifdef notdef
  313. !     .globl    _copyout
  314. !     ALIGN32
  315. ! _copyout:
  316.       movl    _curpcb, %eax
  317.       movl    $cpyflt, PCB_ONFAULT(%eax) # in case we page/protection violate
  318.       pushl    %esi
  319. --- 560,566 ----
  320.       ret
  321.   
  322.   #ifdef notdef
  323. ! CENTRY(copyout)
  324.       movl    _curpcb, %eax
  325.       movl    $cpyflt, PCB_ONFAULT(%eax) # in case we page/protection violate
  326.       pushl    %esi
  327. ***************
  328. *** 655,663 ****
  329.       movl    $ EFAULT,%eax
  330.       ret
  331.   #else
  332. !     .globl    _copyout
  333. !     ALIGN32
  334. ! _copyout:
  335.       movl    _curpcb,%eax
  336.       movl    $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
  337.       pushl    %esi
  338. --- 662,668 ----
  339.       movl    $ EFAULT,%eax
  340.       ret
  341.   #else
  342. ! CENTRY(copyout)
  343.       movl    _curpcb,%eax
  344.       movl    $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
  345.       pushl    %esi
  346. ***************
  347. *** 680,688 ****
  348.       movl    %eax,PCB_ONFAULT(%edx)
  349.       ret
  350.   
  351. !     .globl    _copyin
  352. !     ALIGN32
  353. ! _copyin:
  354.       movl    _curpcb,%eax
  355.       movl    $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
  356.       pushl    %esi
  357. --- 685,691 ----
  358.       movl    %eax,PCB_ONFAULT(%edx)
  359.       ret
  360.   
  361. ! CENTRY(copyin)
  362.       movl    _curpcb,%eax
  363.       movl    $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
  364.       pushl    %esi
  365. ***************
  366. *** 716,724 ****
  367.   #endif
  368.   
  369.       # insb(port,addr,cnt)
  370. !     .globl    _insb
  371. !     ALIGN32
  372. ! _insb:
  373.       pushl    %edi
  374.       movw    8(%esp),%dx
  375.       movl    12(%esp),%edi
  376. --- 719,725 ----
  377.   #endif
  378.   
  379.       # insb(port,addr,cnt)
  380. ! CENTRY(insb)
  381.       pushl    %edi
  382.       movw    8(%esp),%dx
  383.       movl    12(%esp),%edi
  384. ***************
  385. *** 733,741 ****
  386.       ret
  387.   
  388.       # insw(port,addr,cnt)
  389. !     .globl    _insw
  390. !     ALIGN32
  391. ! _insw:
  392.       pushl    %edi
  393.       movw    8(%esp),%dx
  394.       movl    12(%esp),%edi
  395. --- 734,740 ----
  396.       ret
  397.   
  398.       # insw(port,addr,cnt)
  399. ! CENTRY(insw)
  400.       pushl    %edi
  401.       movw    8(%esp),%dx
  402.       movl    12(%esp),%edi
  403. ***************
  404. *** 749,757 ****
  405.       ret
  406.   
  407.       # outsw(port,addr,cnt)
  408. !     .globl    _outsw
  409. !     ALIGN32
  410. ! _outsw:
  411.       pushl    %esi
  412.       movw    8(%esp),%dx
  413.       movl    12(%esp),%esi
  414. --- 748,754 ----
  415.       ret
  416.   
  417.       # outsw(port,addr,cnt)
  418. ! CENTRY(outsw)
  419.       pushl    %esi
  420.       movw    8(%esp),%dx
  421.       movl    12(%esp),%esi
  422. ***************
  423. *** 765,773 ****
  424.       ret
  425.   
  426.       # outsb(port,addr,cnt)
  427. !     .globl    _outsb
  428. !     ALIGN32
  429. ! _outsb:
  430.       pushl    %esi
  431.       movw    8(%esp),%dx
  432.       movl    12(%esp),%esi
  433. --- 762,768 ----
  434.       ret
  435.   
  436.       # outsb(port,addr,cnt)
  437. ! CENTRY(outsb)
  438.       pushl    %esi
  439.       movw    8(%esp),%dx
  440.       movl    12(%esp),%esi
  441. ***************
  442. *** 784,792 ****
  443.       /*
  444.        * void lgdt(struct region_descriptor *rdp);
  445.        */
  446. !     .globl    _lgdt
  447. !     ALIGN32
  448. ! _lgdt:
  449.       /* reload the descriptor table */
  450.       movl    4(%esp),%eax
  451.       lgdt    (%eax)
  452. --- 779,785 ----
  453.       /*
  454.        * void lgdt(struct region_descriptor *rdp);
  455.        */
  456. ! CENTRY(lgdt)
  457.       /* reload the descriptor table */
  458.       movl    4(%esp),%eax
  459.       lgdt    (%eax)
  460. ***************
  461. *** 811,819 ****
  462.       /*
  463.        * void lidt(struct region_descriptor *rdp);
  464.        */
  465. !     .globl    _lidt
  466. !     ALIGN32
  467. ! _lidt:
  468.       movl    4(%esp),%eax
  469.       lidt    (%eax)
  470.       ret
  471. --- 804,810 ----
  472.       /*
  473.        * void lidt(struct region_descriptor *rdp);
  474.        */
  475. ! CENTRY(lidt)
  476.       movl    4(%esp),%eax
  477.       lidt    (%eax)
  478.       ret
  479. ***************
  480. *** 821,829 ****
  481.       /*
  482.        * void lldt(u_short sel)
  483.        */
  484. !     .globl    _lldt
  485. !     ALIGN32
  486. ! _lldt:
  487.       lldt    4(%esp)
  488.       ret
  489.   
  490. --- 812,818 ----
  491.       /*
  492.        * void lldt(u_short sel)
  493.        */
  494. ! CENTRY(lldt)
  495.       lldt    4(%esp)
  496.       ret
  497.   
  498. ***************
  499. *** 830,838 ****
  500.       /*
  501.        * void ltr(u_short sel)
  502.        */
  503. !     .globl    _ltr
  504. !     ALIGN32
  505. ! _ltr:
  506.       ltr    4(%esp)
  507.       ret
  508.   
  509. --- 819,825 ----
  510.       /*
  511.        * void ltr(u_short sel)
  512.        */
  513. ! CENTRY(ltr)
  514.       ltr    4(%esp)
  515.       ret
  516.   
  517. ***************
  518. *** 839,872 ****
  519.       /*
  520.        * void lcr3(caddr_t cr3)
  521.        */
  522. !     .globl    _lcr3
  523. !     .globl    _load_cr3
  524. !     ALIGN32
  525. ! _load_cr3:
  526. ! _lcr3:
  527. !     inb    $0x84,%al    # check wristwatch
  528.       movl    4(%esp),%eax
  529.        orl    $ I386_CR3PAT,%eax
  530.       movl    %eax,%cr3
  531. !     inb    $0x84,%al    # check wristwatch
  532.       ret
  533.   
  534.       # tlbflush()
  535. !     .globl    _tlbflush
  536. !     ALIGN32
  537. ! _tlbflush:
  538. !     inb    $0x84,%al    # check wristwatch
  539.       movl    %cr3,%eax
  540.        orl    $ I386_CR3PAT,%eax
  541.       movl    %eax,%cr3
  542. !     inb    $0x84,%al    # check wristwatch
  543.       ret
  544.   
  545.       # lcr0(cr0)
  546. !     .globl    _lcr0,_load_cr0
  547. !     ALIGN32
  548. ! _lcr0:
  549. ! _load_cr0:
  550.       movl    4(%esp),%eax
  551.       movl    %eax,%cr0
  552.       ret
  553. --- 826,850 ----
  554.       /*
  555.        * void lcr3(caddr_t cr3)
  556.        */
  557. ! CENTRY2(lcr3,load_cr3)
  558. !     NOP1
  559.       movl    4(%esp),%eax
  560.        orl    $ I386_CR3PAT,%eax
  561.       movl    %eax,%cr3
  562. !     NOP1
  563.       ret
  564.   
  565.       # tlbflush()
  566. ! CENTRY(tlbflush)
  567. !     NOP1
  568.       movl    %cr3,%eax
  569.        orl    $ I386_CR3PAT,%eax
  570.       movl    %eax,%cr3
  571. !     NOP1
  572.       ret
  573.   
  574.       # lcr0(cr0)
  575. ! CENTRY2(lcr0,load_cr0)
  576.       movl    4(%esp),%eax
  577.       movl    %eax,%cr0
  578.       ret
  579. ***************
  580. *** 895,903 ****
  581.       ret
  582.   
  583.       # ssdtosd(*ssdp,*sdp)
  584. !     .globl    _ssdtosd
  585. !     ALIGN32
  586. ! _ssdtosd:
  587.       pushl    %ebx
  588.       movl    8(%esp),%ecx
  589.       movl    8(%ecx),%ebx
  590. --- 873,879 ----
  591.       ret
  592.   
  593.       # ssdtosd(*ssdp,*sdp)
  594. ! CENTRY(ssdtosd)
  595.       pushl    %ebx
  596.       movl    8(%esp),%ecx
  597.       movl    8(%ecx),%ebx
  598. ***************
  599. *** 920,928 ****
  600.   /*
  601.    * {fu,su},{byte,word}
  602.    */
  603. !     ALIGN32
  604. ! ALTENTRY(fuiword)
  605. ! ENTRY(fuword)
  606.       movl    _curpcb,%ecx
  607.       movl    $fusufault,PCB_ONFAULT(%ecx)
  608.       movl    4(%esp),%edx
  609. --- 896,902 ----
  610.   /*
  611.    * {fu,su},{byte,word}
  612.    */
  613. ! CENTRY2(fuword,fuiword)
  614.       movl    _curpcb,%ecx
  615.       movl    $fusufault,PCB_ONFAULT(%ecx)
  616.       movl    4(%esp),%edx
  617. ***************
  618. *** 931,938 ****
  619.       movl    $0,PCB_ONFAULT(%ecx)
  620.       ret
  621.       
  622. !     ALIGN32
  623. ! ENTRY(fusword)
  624.       movl    _curpcb,%ecx
  625.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  626.       movl    4(%esp),%edx
  627. --- 905,911 ----
  628.       movl    $0,PCB_ONFAULT(%ecx)
  629.       ret
  630.       
  631. ! CENTRY(fusword)
  632.       movl    _curpcb,%ecx
  633.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  634.       movl    4(%esp),%edx
  635. ***************
  636. *** 941,949 ****
  637.       movl    $0,PCB_ONFAULT(%ecx)
  638.       ret
  639.       
  640. !     ALIGN32
  641. ! ALTENTRY(fuibyte)
  642. ! ENTRY(fubyte)
  643.       movl    _curpcb,%ecx
  644.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  645.       movl    4(%esp),%edx
  646. --- 914,920 ----
  647.       movl    $0,PCB_ONFAULT(%ecx)
  648.       ret
  649.       
  650. ! CENTRY2(fubyte,fuibyte)
  651.       movl    _curpcb,%ecx
  652.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  653.       movl    4(%esp),%edx
  654. ***************
  655. *** 960,968 ****
  656.       decl    %eax
  657.       ret
  658.   
  659. !     ALIGN32
  660. ! ALTENTRY(suiword)
  661. ! ENTRY(suword)
  662.       movl    _curpcb,%ecx
  663.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  664.       movl    4(%esp),%edx
  665. --- 931,937 ----
  666.       decl    %eax
  667.       ret
  668.   
  669. ! CENTRY2(suword,suiword)
  670.       movl    _curpcb,%ecx
  671.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  672.       movl    4(%esp),%edx
  673. ***************
  674. *** 992,999 ****
  675.       movl    %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
  676.       ret
  677.       
  678. !     ALIGN32
  679. ! ENTRY(susword)
  680.       movl    _curpcb,%ecx
  681.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  682.       movl    4(%esp),%edx
  683. --- 961,967 ----
  684.       movl    %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
  685.       ret
  686.       
  687. ! CENTRY(susword)
  688.       movl    _curpcb,%ecx
  689.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  690.       movl    4(%esp),%edx
  691. ***************
  692. *** 1021,1029 ****
  693.       movl    %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
  694.       ret
  695.   
  696. !     ALIGN32
  697. ! ALTENTRY(suibyte)
  698. ! ENTRY(subyte)
  699.       movl    _curpcb,%ecx
  700.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  701.       movl    4(%esp),%edx
  702. --- 989,995 ----
  703.       movl    %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
  704.       ret
  705.   
  706. ! CENTRY2(subyte,suibyte)
  707.       movl    _curpcb,%ecx
  708.       movl    $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
  709.       movl    4(%esp),%edx
  710. ***************
  711. *** 1051,1058 ****
  712.       movl    %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
  713.       ret
  714.   
  715. !     ALIGN32
  716. !     ENTRY(setjmp)
  717.       movl    4(%esp),%eax
  718.       movl    %ebx, 0(%eax)        # save ebx
  719.       movl    %esp, 4(%eax)        # save esp
  720. --- 1017,1023 ----
  721.       movl    %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
  722.       ret
  723.   
  724. ! CENTRY(setjmp)
  725.       movl    4(%esp),%eax
  726.       movl    %ebx, 0(%eax)        # save ebx
  727.       movl    %esp, 4(%eax)        # save esp
  728. ***************
  729. *** 1064,1071 ****
  730.       xorl    %eax,%eax        # return (0);
  731.       ret
  732.   
  733. !     ALIGN32
  734. !     ENTRY(longjmp)
  735.       movl    4(%esp),%eax
  736.       movl     0(%eax),%ebx        # restore ebx
  737.       movl     4(%eax),%esp        # restore esp
  738. --- 1029,1035 ----
  739.       xorl    %eax,%eax        # return (0);
  740.       ret
  741.   
  742. ! CENTRY(longjmp)
  743.       movl    4(%esp),%eax
  744.       movl     0(%eax),%ebx        # restore ebx
  745.       movl     4(%eax),%esp        # restore esp
  746. ***************
  747. *** 1096,1103 ****
  748.    *
  749.    * Call should be made at spl6(), and p->p_stat should be SRUN
  750.    */
  751. !     ALIGN32
  752. ! ENTRY(setrq)
  753.       movl    4(%esp),%eax
  754.       cmpl    $0,P_RLINK(%eax)    # should not be on q already
  755.       je    set1
  756. --- 1060,1066 ----
  757.    *
  758.    * Call should be made at spl6(), and p->p_stat should be SRUN
  759.    */
  760. ! CENTRY(setrq)
  761.       movl    4(%esp),%eax
  762.       cmpl    $0,P_RLINK(%eax)    # should not be on q already
  763.       je    set1
  764. ***************
  765. *** 1123,1130 ****
  766.    *
  767.    * Call should be made at spl6().
  768.    */
  769. !     ALIGN32
  770. ! ENTRY(remrq)
  771.       movl    4(%esp),%eax
  772.       movzbl    P_PRI(%eax),%edx
  773.       shrl    $2,%edx
  774. --- 1086,1092 ----
  775.    *
  776.    * Call should be made at spl6().
  777.    */
  778. ! CENTRY(remrq)
  779.       movl    4(%esp),%eax
  780.       movzbl    P_PRI(%eax),%edx
  781.       shrl    $2,%edx
  782. ***************
  783. *** 1163,1169 ****
  784.       ALIGN32
  785.   Idle:
  786.   idle:
  787. !     call    _spl0
  788.       cmpl    $0,_whichqs
  789.       jne    sw1
  790.       hlt        # wait for interrupt
  791. --- 1125,1131 ----
  792.       ALIGN32
  793.   Idle:
  794.   idle:
  795. !     call    _nmspl0
  796.       cmpl    $0,_whichqs
  797.       jne    sw1
  798.       hlt        # wait for interrupt
  799. ***************
  800. *** 1178,1185 ****
  801.   /*
  802.    * Swtch()
  803.    */
  804. !     ALIGN32
  805. ! ENTRY(swtch)
  806.   
  807.       incl    _cnt+V_SWTCH
  808.   
  809. --- 1140,1146 ----
  810.   /*
  811.    * Swtch()
  812.    */
  813. ! CENTRY(swtch)
  814.   
  815.       incl    _cnt+V_SWTCH
  816.   
  817. ***************
  818. *** 1303,1316 ****
  819.       movl    %edx,_curpcb
  820.   
  821.       /* pushl    PCB_IML(%edx)
  822. !     call    _splx
  823.       popl    %eax*/
  824.   
  825.       movl    %edx,%eax        # return (1);
  826.       ret
  827.   
  828. -     .globl    _mvesp
  829.       ALIGN32
  830.   _mvesp:    movl    %esp,%eax
  831.       ret
  832.   /*
  833. --- 1264,1277 ----
  834.       movl    %edx,_curpcb
  835.   
  836.       /* pushl    PCB_IML(%edx)
  837. !     call    _nmsplx
  838.       popl    %eax*/
  839.   
  840.       movl    %edx,%eax        # return (1);
  841.       ret
  842.   
  843.       ALIGN32
  844. +     .globl    _mvesp
  845.   _mvesp:    movl    %esp,%eax
  846.       ret
  847.   /*
  848. ***************
  849. *** 1322,1329 ****
  850.    * Since this code requires a parameter from the "old" stack,
  851.    * pass it back as a return value.
  852.    */
  853. !     ALIGN32
  854. ! ENTRY(swtch_to_inactive)
  855.       popl    %edx            # old pc
  856.       popl    %eax            # arg, our return value
  857.       movl    _IdlePTD,%ecx
  858. --- 1283,1289 ----
  859.    * Since this code requires a parameter from the "old" stack,
  860.    * pass it back as a return value.
  861.    */
  862. ! CENTRY(swtch_to_inactive)
  863.       popl    %edx            # old pc
  864.       popl    %eax            # arg, our return value
  865.       movl    _IdlePTD,%ecx
  866. ***************
  867. *** 1337,1344 ****
  868.    * Update pcb, saving current processor state and arranging
  869.    * for alternate return ala longjmp in swtch if altreturn is true.
  870.    */
  871. !     ALIGN32
  872. ! ENTRY(savectx)
  873.       movl    4(%esp), %ecx
  874.       movw    _cpl, %ax
  875.       movw    %ax,  PCB_IML(%ecx)
  876. --- 1297,1303 ----
  877.    * Update pcb, saving current processor state and arranging
  878.    * for alternate return ala longjmp in swtch if altreturn is true.
  879.    */
  880. ! CENTRY(savectx)
  881.       movl    4(%esp), %ecx
  882.       movw    _cpl, %ax
  883.       movw    %ax,  PCB_IML(%ecx)
  884. ***************
  885. *** 1388,1395 ****
  886.    * update profiling information for the user process.
  887.    */
  888.   
  889. !     ALIGN32
  890. ! ENTRY(addupc)
  891.       pushl %ebp
  892.       movl %esp,%ebp
  893.       movl 12(%ebp),%edx        /* up */
  894. --- 1347,1353 ----
  895.    * update profiling information for the user process.
  896.    */
  897.   
  898. ! CENTRY(addupc)
  899.       pushl %ebp
  900.       movl %esp,%ebp
  901.       movl 12(%ebp),%edx        /* up */
  902. ***************
  903. *** 1541,1547 ****
  904.   calltrap:
  905.       incl    _cnt+V_TRAP
  906.       call    _trap
  907. !     call    _spl0
  908.       pop %es
  909.       pop %ds
  910.       popal
  911. --- 1499,1505 ----
  912.   calltrap:
  913.       incl    _cnt+V_TRAP
  914.       call    _trap
  915. !     call    _nmspl0
  916.       pop %es
  917.       pop %ds
  918.       popal
  919. ***************
  920. *** 1585,1591 ****
  921.       movw    %ax,%ds
  922.       movw    %ax,%es
  923.       call    _syscall
  924. !     call    _spl0
  925.       movw    __udatasel,%ax    # switch back to user segments
  926.       movw    %ax,%ds
  927.       movw    %ax,%es
  928. --- 1543,1549 ----
  929.       movw    %ax,%ds
  930.       movw    %ax,%es
  931.       call    _syscall
  932. !     call    _nmspl0
  933.       movw    __udatasel,%ax    # switch back to user segments
  934.       movw    %ax,%ds
  935.       movw    %ax,%es
  936. ***************
  937. *** 1594,1602 ****
  938.       popfl
  939.       lret
  940.   
  941. !     ALIGN32
  942. ! ENTRY(htonl)
  943. ! ENTRY(ntohl)
  944.       movl    4(%esp),%eax
  945.       xchgb    %al,%ah
  946.       roll    $16,%eax
  947. --- 1552,1558 ----
  948.       popfl
  949.       lret
  950.   
  951. ! CENTRY2(ntohl,htonl)
  952.       movl    4(%esp),%eax
  953.       xchgb    %al,%ah
  954.       roll    $16,%eax
  955. ***************
  956. *** 1603,1611 ****
  957.       xchgb    %al,%ah
  958.       ret
  959.   
  960. !     ALIGN32
  961. ! ENTRY(htons)
  962. ! ENTRY(ntohs)
  963.       movzwl    4(%esp),%eax
  964.       xchgb    %al,%ah
  965.       ret
  966. --- 1559,1565 ----
  967.       xchgb    %al,%ah
  968.       ret
  969.   
  970. ! CENTRY2(ntohs,htons)
  971.       movzwl    4(%esp),%eax
  972.       xchgb    %al,%ah
  973.       ret
  974. *** ./i386/isa/icu.s.pre    Sun Jan 24 22:58:30 1993
  975. --- ./i386/isa/icu.s    Wed Jan 27 02:14:37 1993
  976. ***************
  977. *** 123,129 ****
  978.       call    c ; \
  979.   1:
  980.   
  981. !     call    _splnet
  982.   
  983.       DONET(NETISR_RAW,_rawintr)
  984.   #ifdef INET
  985. --- 123,129 ----
  986.       call    c ; \
  987.   1:
  988.   
  989. !     call    _nmsplnet
  990.   
  991.       DONET(NETISR_RAW,_rawintr)
  992.   #ifdef INET
  993. ***************
  994. *** 147,163 ****
  995.       outb    %al,$ IO_ICU2+1
  996.       NOP
  997.   #else
  998. !     call    _spl0
  999.   #endif
  1000.   
  1001.       btrl    $ NETISR_SCLK,_netisr
  1002.       jnb    1f
  1003.       # back to an interrupt frame for a moment
  1004. !     call    _splsoftclock
  1005.       pushl    $0xff    # dummy intr
  1006.       call    _softclock
  1007.       popl    %eax
  1008. !     call    _spl0
  1009.   
  1010.       # jmp    2f
  1011.   
  1012. --- 147,163 ----
  1013.       outb    %al,$ IO_ICU2+1
  1014.       NOP
  1015.   #else
  1016. !     call    _nmspl0
  1017.   #endif
  1018.   
  1019.       btrl    $ NETISR_SCLK,_netisr
  1020.       jnb    1f
  1021.       # back to an interrupt frame for a moment
  1022. !     call    _nmsplsoftclock
  1023.       pushl    $0xff    # dummy intr
  1024.       call    _softclock
  1025.       popl    %eax
  1026. !     call    _nmspl0
  1027.   
  1028.       # jmp    2f
  1029.   
  1030. ***************
  1031. *** 177,296 ****
  1032.   /*
  1033.    * Interrupt priority mechanism
  1034.    *
  1035. -  * Two flavors    -- imlXX masks relative to ISA noemenclature (for PC compat sw)
  1036.    *        -- splXX masks with group mechanism for BSD purposes
  1037.    */
  1038.   
  1039. !     .globl    _splhigh
  1040. !     .globl    _splclock
  1041. !     ALIGN32
  1042. ! _splhigh:
  1043. ! _splclock:
  1044. !     cli                # disable interrupts
  1045. !     NOP
  1046. !     movw    $0xffff,%ax        # set new priority level
  1047. !     movw    %ax,%dx
  1048. !     # orw    _imen,%ax        # mask off those not enabled yet
  1049. !     movw    %ax,%cx
  1050. !     outb    %al,$ IO_ICU1+1        /* update icu's */
  1051. !     NOP
  1052. !     movb    %ah,%al
  1053. !     outb    %al,$ IO_ICU2+1
  1054. !     NOP
  1055. !     movzwl    _cpl,%eax        # return old priority
  1056. !     movw    %dx,_cpl        # set new priority level
  1057. !     sti                # enable interrupts
  1058. !     ret
  1059. !     .globl    _spltty            # block clists
  1060. !     ALIGN32
  1061. ! _spltty:
  1062. !     cli                # disable interrupts
  1063. !     NOP
  1064. !     movw    _cpl,%ax
  1065. !     orw    _ttymask,%ax
  1066. !     movw    %ax,%dx
  1067. !     orw    _imen,%ax        # mask off those not enabled yet
  1068. !     movw    %ax,%cx
  1069. !     outb    %al,$ IO_ICU1+1        /* update icu's */
  1070. !     NOP
  1071. !     movb    %ah,%al
  1072. !     outb    %al,$ IO_ICU2+1
  1073. !     NOP
  1074. !     movzwl    _cpl,%eax        # return old priority
  1075. !     movw    %dx,_cpl        # set new priority level
  1076. !     sti                # enable interrupts
  1077. !     ret
  1078.   
  1079. !     .globl    _splimp
  1080. !     .globl    _splnet
  1081. !     ALIGN32
  1082. ! _splimp:
  1083. ! _splnet:
  1084. !     cli                # disable interrupts
  1085. !     NOP
  1086. !     movw    _cpl,%ax
  1087. !     orw    _netmask,%ax
  1088. !     movw    %ax,%dx
  1089. !     orw    _imen,%ax        # mask off those not enabled yet
  1090. !     movw    %ax,%cx
  1091. !     outb    %al,$ IO_ICU1+1        /* update icu's */
  1092. !     NOP
  1093. !     movb    %ah,%al
  1094. !     outb    %al,$ IO_ICU2+1
  1095. !     NOP
  1096. !     movzwl    _cpl,%eax        # return old priority
  1097. !     movw    %dx,_cpl        # set new priority level
  1098. !     sti                # enable interrupts
  1099.       ret
  1100.   
  1101. -     .globl    _splbio    
  1102. -     ALIGN32
  1103. - _splbio:
  1104. -     cli                # disable interrupts
  1105. -     NOP
  1106. -     movw    _cpl,%ax
  1107. -     orw    _biomask,%ax
  1108. -     movw    %ax,%dx
  1109. -     orw    _imen,%ax        # mask off those not enabled yet
  1110. -     movw    %ax,%cx
  1111. -     outb    %al,$ IO_ICU1+1        /* update icu's */
  1112. -     NOP
  1113. -     movb    %ah,%al
  1114. -     outb    %al,$ IO_ICU2+1
  1115. -     NOP
  1116. -     movzwl    _cpl,%eax        # return old priority
  1117. -     movw    %dx,_cpl        # set new priority level
  1118. -     sti                # enable interrupts
  1119. -     ret
  1120.   
  1121. !     .globl    _splsoftclock
  1122. !     ALIGN32
  1123. ! _splsoftclock:
  1124.       cli                # disable interrupts
  1125.       NOP
  1126. !     movw    _cpl,%ax
  1127. !     orw    $0x8000,%ax        # set new priority level
  1128. !     movw    %ax,%dx
  1129. !     orw    _imen,%ax        # mask off those not enabled yet
  1130. !     movw    %ax,%cx
  1131. !     outb    %al,$ IO_ICU1+1        /* update icu's */
  1132. !     NOP
  1133. !     movb    %ah,%al
  1134. !     outb    %al,$ IO_ICU2+1
  1135. !     NOP
  1136. !     movzwl    _cpl,%eax        # return old priority
  1137. !     movw    %dx,_cpl        # set new priority level
  1138. !     sti                # enable interrupts
  1139. !     ret
  1140.   
  1141. -     .globl _splnone
  1142. -     .globl _spl0
  1143. -     ALIGN32
  1144. - _splnone:
  1145. - _spl0:
  1146. -     cli                # disable interrupts
  1147. -     NOP
  1148.       pushl    _cpl            # save old priority
  1149.       movw    _cpl,%ax
  1150.       orw    _netmask,%ax        # mask off those network devices
  1151. --- 177,235 ----
  1152.   /*
  1153.    * Interrupt priority mechanism
  1154.    *
  1155.    *        -- splXX masks with group mechanism for BSD purposes
  1156.    */
  1157.   
  1158. ! #define NMENTRY(x)     .globl _nm/**/x; _nm/**/x:
  1159.   
  1160. ! #define SPL(mask) \
  1161. !     cli            ; /* turn off interrupts */ \
  1162. !     NOP             ; /* wait a little */ \
  1163. !     movzwl    _cpl,%eax     ; /* get cpl */ \
  1164. !     movl    %eax,%ecx    ; /* ... and save it */ \
  1165. !     orw    mask,%ax    ; /* compute new cpl */ \
  1166. !     cmpw    %ax,%cx        ; /* same as old? */ \
  1167. !     je    1f        ; /* yes, skip ICU manipulation */ \
  1168. !     movw    %ax,_cpl    ; /* save new cpl */ \
  1169. !     orw    _imen,%ax    ; /* mask off disabled interrupts */ \
  1170. !     outb    %al,$ IO_ICU1+1    ; /* juggle the ICU */ \
  1171. !     NOP             ; \
  1172. !     movb    %ah,%al        ; \
  1173. !     outb    %al,$ IO_ICU2+1    ; \
  1174. !     NOP            ; \
  1175. !     movl    %ecx,%eax    ; /* use old cpl as return value */ \
  1176. ! 1:                ; \
  1177. !     sti            ; /* enable interrupts again */ \
  1178.       ret
  1179.   
  1180.   
  1181. ! CENTRY2(splhigh,splclock)
  1182. ! NMENTRY(splhigh)
  1183. ! NMENTRY(splclock)
  1184. !     SPL($0xffff)
  1185. ! CENTRY(spltty)                # block clists
  1186. !     SPL(_ttymask)
  1187. ! CENTRY2(splimp,splnet)
  1188. ! NMENTRY(splnet)
  1189. !     SPL(_netmask)
  1190. ! CENTRY(splbio)
  1191. !     SPL(_biomask)
  1192. ! CENTRY(splsoftclock)
  1193. ! NMENTRY(splsoftclock)
  1194. !     SPL($0x8000)
  1195. ! CENTRY2(splnone,spl0)
  1196. ! NMENTRY(spl0)
  1197. ! Lspl0jmp:
  1198.       cli                # disable interrupts
  1199.       NOP
  1200. !     cmpl    $0,_netisr
  1201. !     je    Lspl0
  1202.   
  1203.       pushl    _cpl            # save old priority
  1204.       movw    _cpl,%ax
  1205.       orw    _netmask,%ax        # mask off those network devices
  1206. ***************
  1207. *** 310,319 ****
  1208.       cli                # disable interrupts
  1209.       popl    _cpl            # save old priority
  1210.       NOP
  1211. !     movw    $0,%ax            # set new priority level
  1212. !     movw    %ax,%dx
  1213. !     orw    _imen,%ax        # mask off those not enabled yet
  1214. !     movw    %ax,%cx
  1215.       outb    %al,$ IO_ICU1+1        /* update icu's */
  1216.       NOP
  1217.       movb    %ah,%al
  1218. --- 249,256 ----
  1219.       cli                # disable interrupts
  1220.       popl    _cpl            # save old priority
  1221.       NOP
  1222. ! Lspl0:
  1223. !     movw    _imen,%ax        # mask off those not enabled yet
  1224.       outb    %al,$ IO_ICU1+1        /* update icu's */
  1225.       NOP
  1226.       movb    %ah,%al
  1227. ***************
  1228. *** 320,339 ****
  1229.       outb    %al,$ IO_ICU2+1
  1230.       NOP
  1231.       movzwl    _cpl,%eax        # return old priority
  1232. !     movw    %dx,_cpl        # set new priority level
  1233.       sti                # enable interrupts
  1234.       ret
  1235.   
  1236. !     .globl _splx
  1237. !     ALIGN32
  1238. ! _splx:
  1239.       cli                # disable interrupts
  1240.       NOP
  1241.       movw    4(%esp),%ax        # new priority level
  1242.       movw    %ax,%dx
  1243.       cmpw    $0,%dx
  1244. !     je    _spl0            # going to "zero level" is special
  1245.   
  1246.       orw    _imen,%ax        # mask off those not enabled yet
  1247.       movw    %ax,%cx
  1248.       outb    %al,$ IO_ICU1+1        /* update icu's */
  1249. --- 257,278 ----
  1250.       outb    %al,$ IO_ICU2+1
  1251.       NOP
  1252.       movzwl    _cpl,%eax        # return old priority
  1253. !     movw    $0,_cpl            # set new priority level
  1254.       sti                # enable interrupts
  1255.       ret
  1256.   
  1257. ! CENTRY(splx)
  1258. ! NMENTRY(splx)
  1259.       cli                # disable interrupts
  1260.       NOP
  1261.       movw    4(%esp),%ax        # new priority level
  1262.       movw    %ax,%dx
  1263.       cmpw    $0,%dx
  1264. !     je    Lspl0jmp        # going to "zero level" is special
  1265.   
  1266. +     cmpw    %dx,_cpl        # same as we have now ?
  1267. +     je    1f            # yes, skip ICU handling
  1268.       orw    _imen,%ax        # mask off those not enabled yet
  1269.       movw    %ax,%cx
  1270.       outb    %al,$ IO_ICU1+1        /* update icu's */
  1271. ***************
  1272. *** 341,346 ****
  1273. --- 280,286 ----
  1274.       movb    %ah,%al
  1275.       outb    %al,$ IO_ICU2+1
  1276.       NOP
  1277. + 1:
  1278.       movzwl    _cpl,%eax        # return old priority
  1279.       movw    %dx,_cpl        # set new priority level
  1280.       sti                # enable interrupts
  1281.  
  1282. -- 
  1283.  
  1284.     -- Lennart Augustsson
  1285. [This signature is intentionally left blank.]
  1286.