It simply makes certain kernel routines a tiny bit faster. I
noticed that branch/function call addresses and some data items in
'/sys/i386/i386/locore.s' and '/sys/i386/isa/icu.s' are not aligned on
32 bit word boundaries (0 modulo 4). This causes a small performance
hit on 386DX/486 based machines. I aligned things on 4 byte boundaries
using a macro, ALIGN32, to perform the alignment since the new version
of the Gnu assembler will probably change the meaning of .align 2. I
also eliminated an unnecessary instruction in ___divsi3. I don't claim
a profound performance boost, but every little bit helps!
AUTHOR: Frank MacLachlan (fpm@crash.cts.com)
386BSD-Patchkit: patch00064
*
* PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
* -------------------- ----- ----------------------
*
* PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
* -------------------- ----- ----------------------
- * CURRENT PATCH LEVEL: 1 00030
+ * CURRENT PATCH LEVEL: 2 00064
* -------------------- ----- ----------------------
*
* 06 Aug 92 Pace Willisson Allow VGA memory to be mapped
* -------------------- ----- ----------------------
*
* 06 Aug 92 Pace Willisson Allow VGA memory to be mapped
+ * 28 Nov 92 Frank MacLachlan Aligned addresses and data
+ * on 32bit boundaries.
.set SYSPDROFF,0x3F8 # Page dir index of System Base
#define NOP inb $0x84, %al ; inb $0x84, %al
.set SYSPDROFF,0x3F8 # Page dir index of System Base
#define NOP inb $0x84, %al ; inb $0x84, %al
+#define ALIGN32 .align 2 /* 2^2 = 4 */
/*
* PTmap is recursive pagemap at top of virtual address space.
/*
* PTmap is recursive pagemap at top of virtual address space.
* Support routines for GCC
*/
.globl ___udivsi3
* Support routines for GCC
*/
.globl ___udivsi3
___udivsi3:
movl 4(%esp),%eax
xorl %edx,%edx
___udivsi3:
movl 4(%esp),%eax
xorl %edx,%edx
___divsi3:
movl 4(%esp),%eax
___divsi3:
movl 4(%esp),%eax
+ #xorl %edx,%edx /* not needed - cltd sign extends into %edx */
* I/O bus instructions via C
*/
.globl _inb
* I/O bus instructions via C
*/
.globl _inb
_inb: movl 4(%esp),%edx
subl %eax,%eax # clr eax
NOP
_inb: movl 4(%esp),%edx
subl %eax,%eax # clr eax
NOP
_inw: movl 4(%esp),%edx
subl %eax,%eax # clr eax
NOP
_inw: movl 4(%esp),%edx
subl %eax,%eax # clr eax
NOP
_rtcin: movl 4(%esp),%eax
outb %al,$0x70
subl %eax,%eax # clr eax
_rtcin: movl 4(%esp),%eax
outb %al,$0x70
subl %eax,%eax # clr eax
_outb: movl 4(%esp),%edx
NOP
movl 8(%esp),%eax
_outb: movl 4(%esp),%edx
NOP
movl 8(%esp),%eax
_outw: movl 4(%esp),%edx
NOP
movl 8(%esp),%eax
_outw: movl 4(%esp),%edx
NOP
movl 8(%esp),%eax
_bzero:
pushl %edi
movl 8(%esp),%edi
_bzero:
pushl %edi
movl 8(%esp),%edi
_fillw:
pushl %edi
movl 8(%esp),%eax
_fillw:
pushl %edi
movl 8(%esp),%eax
_bcopyb:
pushl %esi
pushl %edi
_bcopyb:
pushl %esi
pushl %edi
*/
.globl _bcopy,_ovbcopy
*/
.globl _bcopy,_ovbcopy
_ovbcopy:
_bcopy:
pushl %esi
_ovbcopy:
_bcopy:
pushl %esi
popl %esi
xorl %eax,%eax
ret
popl %esi
xorl %eax,%eax
ret
1:
addl %ecx,%edi /* copy backwards. */
addl %ecx,%esi
1:
addl %ecx,%edi /* copy backwards. */
addl %ecx,%esi
#ifdef notdef
.globl _copyout
#ifdef notdef
.globl _copyout
_copyout:
movl _curpcb, %eax
movl $cpyflt, PCB_ONFAULT(%eax) # in case we page/protection violate
_copyout:
movl _curpcb, %eax
movl $cpyflt, PCB_ONFAULT(%eax) # in case we page/protection violate
_copyin:
movl _curpcb,%eax
movl $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
_copyin:
movl _curpcb,%eax
movl $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
movl %eax,PCB_ONFAULT(%edx)
ret
movl %eax,PCB_ONFAULT(%edx)
ret
cpyflt:
popl %ebx
popl %edi
cpyflt:
popl %ebx
popl %edi
ret
#else
.globl _copyout
ret
#else
.globl _copyout
_copyout:
movl _curpcb,%eax
movl $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
_copyout:
movl _curpcb,%eax
movl $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
_copyin:
movl _curpcb,%eax
movl $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
_copyin:
movl _curpcb,%eax
movl $cpyflt,PCB_ONFAULT(%eax) # in case we page/protection violate
movl %eax,PCB_ONFAULT(%edx)
ret
movl %eax,PCB_ONFAULT(%edx)
ret
cpyflt: popl %edi
popl %esi
movl _curpcb,%edx
cpyflt: popl %edi
popl %esi
movl _curpcb,%edx
# insb(port,addr,cnt)
.globl _insb
# insb(port,addr,cnt)
.globl _insb
_insb:
pushl %edi
movw 8(%esp),%dx
_insb:
pushl %edi
movw 8(%esp),%dx
# insw(port,addr,cnt)
.globl _insw
# insw(port,addr,cnt)
.globl _insw
_insw:
pushl %edi
movw 8(%esp),%dx
_insw:
pushl %edi
movw 8(%esp),%dx
# outsw(port,addr,cnt)
.globl _outsw
# outsw(port,addr,cnt)
.globl _outsw
_outsw:
pushl %esi
movw 8(%esp),%dx
_outsw:
pushl %esi
movw 8(%esp),%dx
# outsb(port,addr,cnt)
.globl _outsb
# outsb(port,addr,cnt)
.globl _outsb
_outsb:
pushl %esi
movw 8(%esp),%dx
_outsb:
pushl %esi
movw 8(%esp),%dx
* void lgdt(struct region_descriptor *rdp);
*/
.globl _lgdt
* void lgdt(struct region_descriptor *rdp);
*/
.globl _lgdt
_lgdt:
/* reload the descriptor table */
movl 4(%esp),%eax
_lgdt:
/* reload the descriptor table */
movl 4(%esp),%eax
* void lidt(struct region_descriptor *rdp);
*/
.globl _lidt
* void lidt(struct region_descriptor *rdp);
*/
.globl _lidt
_lidt:
movl 4(%esp),%eax
lidt (%eax)
_lidt:
movl 4(%esp),%eax
lidt (%eax)
* void lldt(u_short sel)
*/
.globl _lldt
* void lldt(u_short sel)
*/
.globl _lldt
* void ltr(u_short sel)
*/
.globl _ltr
* void ltr(u_short sel)
*/
.globl _ltr
*/
.globl _lcr3
.globl _load_cr3
*/
.globl _lcr3
.globl _load_cr3
_load_cr3:
_lcr3:
inb $0x84,%al # check wristwatch
_load_cr3:
_lcr3:
inb $0x84,%al # check wristwatch
# tlbflush()
.globl _tlbflush
# tlbflush()
.globl _tlbflush
_tlbflush:
inb $0x84,%al # check wristwatch
movl %cr3,%eax
_tlbflush:
inb $0x84,%al # check wristwatch
movl %cr3,%eax
# lcr0(cr0)
.globl _lcr0,_load_cr0
# lcr0(cr0)
.globl _lcr0,_load_cr0
_lcr0:
_load_cr0:
movl 4(%esp),%eax
_lcr0:
_load_cr0:
movl 4(%esp),%eax
_rcr0:
movl %cr0,%eax
ret
# rcr2()
.globl _rcr2
_rcr0:
movl %cr0,%eax
ret
# rcr2()
.globl _rcr2
_rcr2:
movl %cr2,%eax
ret
_rcr2:
movl %cr2,%eax
ret
# rcr3()
.globl _rcr3
.globl __cr3
# rcr3()
.globl _rcr3
.globl __cr3
__cr3:
_rcr3:
movl %cr3,%eax
__cr3:
_rcr3:
movl %cr3,%eax
# ssdtosd(*ssdp,*sdp)
.globl _ssdtosd
# ssdtosd(*ssdp,*sdp)
.globl _ssdtosd
_ssdtosd:
pushl %ebx
movl 8(%esp),%ecx
_ssdtosd:
pushl %ebx
movl 8(%esp),%ecx
/*
* {fu,su},{byte,word}
*/
/*
* {fu,su},{byte,word}
*/
ALTENTRY(fuiword)
ENTRY(fuword)
movl _curpcb,%ecx
ALTENTRY(fuiword)
ENTRY(fuword)
movl _curpcb,%ecx
movl $0,PCB_ONFAULT(%ecx)
ret
movl $0,PCB_ONFAULT(%ecx)
ret
ENTRY(fusword)
movl _curpcb,%ecx
movl $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
ENTRY(fusword)
movl _curpcb,%ecx
movl $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
movl $0,PCB_ONFAULT(%ecx)
ret
movl $0,PCB_ONFAULT(%ecx)
ret
ALTENTRY(fuibyte)
ENTRY(fubyte)
movl _curpcb,%ecx
ALTENTRY(fuibyte)
ENTRY(fubyte)
movl _curpcb,%ecx
movl $0,PCB_ONFAULT(%ecx)
ret
movl $0,PCB_ONFAULT(%ecx)
ret
fusufault:
movl _curpcb,%ecx
xorl %eax,%eax
fusufault:
movl _curpcb,%ecx
xorl %eax,%eax
ALTENTRY(suiword)
ENTRY(suword)
movl _curpcb,%ecx
ALTENTRY(suiword)
ENTRY(suword)
movl _curpcb,%ecx
movl %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
ret
movl %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
ret
ENTRY(susword)
movl _curpcb,%ecx
movl $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
ENTRY(susword)
movl _curpcb,%ecx
movl $fusufault,PCB_ONFAULT(%ecx) #in case we page/protection violate
movl %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
ret
movl %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
ret
ALTENTRY(suibyte)
ENTRY(subyte)
movl _curpcb,%ecx
ALTENTRY(suibyte)
ENTRY(subyte)
movl _curpcb,%ecx
movl %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
ret
movl %eax,PCB_ONFAULT(%ecx) #in case we page/protection violate
ret
ENTRY(setjmp)
movl 4(%esp),%eax
movl %ebx, 0(%eax) # save ebx
ENTRY(setjmp)
movl 4(%esp),%eax
movl %ebx, 0(%eax) # save ebx
xorl %eax,%eax # return (0);
ret
xorl %eax,%eax # return (0);
ret
ENTRY(longjmp)
movl 4(%esp),%eax
movl 0(%eax),%ebx # restore ebx
ENTRY(longjmp)
movl 4(%esp),%eax
movl 0(%eax),%ebx # restore ebx
*
* Call should be made at spl6(), and p->p_stat should be SRUN
*/
*
* Call should be made at spl6(), and p->p_stat should be SRUN
*/
ENTRY(setrq)
movl 4(%esp),%eax
cmpl $0,P_RLINK(%eax) # should not be on q already
ENTRY(setrq)
movl 4(%esp),%eax
cmpl $0,P_RLINK(%eax) # should not be on q already
*
* Call should be made at spl6().
*/
*
* Call should be made at spl6().
*/
ENTRY(remrq)
movl 4(%esp),%eax
movzbl P_PRI(%eax),%edx
ENTRY(remrq)
movl 4(%esp),%eax
movzbl P_PRI(%eax),%edx
* to wait for something to come ready.
*/
.globl Idle
* to wait for something to come ready.
*/
.globl Idle
ENTRY(swtch)
incl _cnt+V_SWTCH
ENTRY(swtch)
incl _cnt+V_SWTCH
_mvesp: movl %esp,%eax
ret
/*
_mvesp: movl %esp,%eax
ret
/*
* Since this code requires a parameter from the "old" stack,
* pass it back as a return value.
*/
* Since this code requires a parameter from the "old" stack,
* pass it back as a return value.
*/
ENTRY(swtch_to_inactive)
popl %edx # old pc
popl %eax # arg, our return value
ENTRY(swtch_to_inactive)
popl %edx # old pc
popl %eax # arg, our return value
* Update pcb, saving current processor state and arranging
* for alternate return ala longjmp in swtch if altreturn is true.
*/
* Update pcb, saving current processor state and arranging
* for alternate return ala longjmp in swtch if altreturn is true.
*/
ENTRY(savectx)
movl 4(%esp), %ecx
movw _cpl, %ax
ENTRY(savectx)
movl 4(%esp), %ecx
movw _cpl, %ax
* update profiling information for the user process.
*/
* update profiling information for the user process.
*/
ENTRY(addupc)
pushl %ebp
movl %esp,%ebp
ENTRY(addupc)
pushl %ebp
movl %esp,%ebp
proffault:
/* if we get a fault, then kill profiling all together */
movl $0,PCB_ONFAULT(%edx) /* squish the fault handler */
proffault:
/* if we get a fault, then kill profiling all together */
movl $0,PCB_ONFAULT(%edx) /* squish the fault handler */
.globl _cyloffset, _curpcb
_cyloffset: .long 0
.globl _proc0paddr
.globl _cyloffset, _curpcb
_cyloffset: .long 0
.globl _proc0paddr
IDTVEC(rsvd14)
pushl $0; TRAP(31)
IDTVEC(rsvd14)
pushl $0; TRAP(31)
* This code checks for a kgdb trap, then falls through
* to the regular trap code.
*/
* This code checks for a kgdb trap, then falls through
* to the regular trap code.
*/
* Call gate entry for syscall
*/
* Call gate entry for syscall
*/
IDTVEC(syscall)
pushfl # only for stupid carry bit and more stupid wait3 cc kludge
pushal # only need eax,ecx,edx - trap resaves others
IDTVEC(syscall)
pushfl # only for stupid carry bit and more stupid wait3 cc kludge
pushal # only need eax,ecx,edx - trap resaves others
ENTRY(htonl)
ENTRY(ntohl)
movl 4(%esp),%eax
ENTRY(htonl)
ENTRY(ntohl)
movl 4(%esp),%eax
ENTRY(htons)
ENTRY(ntohs)
movzwl 4(%esp),%eax
ENTRY(htons)
ENTRY(ntohs)
movzwl 4(%esp),%eax
* SUCH DAMAGE.
*
* @(#)icu.s 7.2 (Berkeley) 5/21/91
* SUCH DAMAGE.
*
* @(#)icu.s 7.2 (Berkeley) 5/21/91
+ *
+ * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
+ * -------------------- ----- ----------------------
+ * CURRENT PATCH LEVEL: 1 00064
+ * -------------------- ----- ----------------------
+ *
+ * 28 Nov 92 Frank MacLachlan Aligned addresses and data
+ * on 32bit boundaries.
.globl _imen
.globl _cpl
_cpl: .long 0xffff # current priority level (all off)
.globl _imen
.globl _cpl
_cpl: .long 0xffff # current priority level (all off)
/*
* Handle return from interrupt after device handler finishes
*/
/*
* Handle return from interrupt after device handler finishes
*/
doreti:
cli
popl %ebx # remove intr number
doreti:
cli
popl %ebx # remove intr number
1: cmpl $0,_netisr # check for softint s/traps
jne 1f
cmpl $0,_want_resched
1: cmpl $0,_netisr # check for softint s/traps
jne 1f
cmpl $0,_want_resched
#include "../net/netisr.h"
#include "../net/netisr.h"
1:
#define DONET(s, c) ; \
1:
#define DONET(s, c) ; \
.globl _splhigh
.globl _splclock
.globl _splhigh
.globl _splclock
_splhigh:
_splclock:
cli # disable interrupts
_splhigh:
_splclock:
cli # disable interrupts
ret
.globl _spltty # block clists
ret
.globl _spltty # block clists
_spltty:
cli # disable interrupts
NOP
_spltty:
cli # disable interrupts
NOP
.globl _splimp
.globl _splnet
.globl _splimp
.globl _splnet
_splimp:
_splnet:
cli # disable interrupts
_splimp:
_splnet:
cli # disable interrupts
_splbio:
cli # disable interrupts
NOP
_splbio:
cli # disable interrupts
NOP
_splsoftclock:
cli # disable interrupts
NOP
_splsoftclock:
cli # disable interrupts
NOP
.globl _splnone
.globl _spl0
.globl _splnone
.globl _spl0
_splnone:
_spl0:
cli # disable interrupts
_splnone:
_spl0:
cli # disable interrupts
_splx:
cli # disable interrupts
NOP
_splx:
cli # disable interrupts
NOP