Define ovbcopy() as a macro which expands to the equivalent bcopy() call,

to take care of the KAME IPv6 code which needs ovbcopy() because NetBSD's
bcopy() doesn't handle overlap like ours.

Remove all implementations of ovbcopy().

Previously, bzero was a function pointer on i386, to save a jmp to
bzero_vector.  Get rid of this microoptimization as it only confuses
things, adds machine-dependent code to an MD header, and doesn't really
save all that much.

This commit does not add my pagezero() / pagecopy() code.
This commit is contained in:
Dag-Erling Smørgrav 2003-04-04 17:29:55 +00:00
parent a12b1b124a
commit 9f45b2da8f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113090
16 changed files with 41 additions and 73 deletions

View File

@ -270,16 +270,11 @@ NESTED(copyoutstr, 4, 16, ra, 0, 0)
/*
* Copy a bytes within the kernel's address space.
*
* In the kernel, bcopy() doesn't have to handle the overlapping
* case; that's that ovbcopy() is for. However, it doesn't hurt
* to do both in bcopy, and it does provide a measure of safety.
* Handles overlapping regions.
*
* void bcopy(char *from, char *to, size_t len);
* void ovbcopy(char *from, char *to, size_t len);
*/
LEAF(bcopy,3)
XLEAF(ovbcopy,3)
/* Check for negative length */
ble a2,bcopy_done

View File

@ -507,12 +507,10 @@ npx_attach(dev)
if (cpu_class == CPUCLASS_586 && npx_ex16 && npx_exists &&
timezero("i586_bzero()", i586_bzero) <
timezero("bzero()", bzero) * 4 / 5) {
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) {
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY))
bcopy_vector = i586_bcopy;
ovbcopy_vector = i586_bcopy;
}
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BZERO))
bzero = i586_bzero;
bzero_vector = i586_bzero;
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) {
copyin_vector = i586_copyin;
copyout_vector = i586_copyout;

View File

@ -563,7 +563,7 @@ printcpuinfo(void)
#if defined(I486_CPU)
case CPUCLASS_486:
printf("486");
bzero = i486_bzero;
bzero_vector = i486_bzero;
break;
#endif
#if defined(I586_CPU)

View File

@ -48,8 +48,8 @@
.globl bcopy_vector
bcopy_vector:
.long generic_bcopy
.globl bzero
bzero:
.globl bzero_vector
bzero_vector:
.long generic_bzero
.globl copyin_vector
copyin_vector:
@ -57,9 +57,6 @@ copyin_vector:
.globl copyout_vector
copyout_vector:
.long generic_copyout
.globl ovbcopy_vector
ovbcopy_vector:
.long generic_bcopy
#if defined(I586_CPU) && defined(DEV_NPX)
kernel_fpu_lock:
.byte 0xfe
@ -73,6 +70,10 @@ kernel_fpu_lock:
* void bzero(void *buf, u_int len)
*/
ENTRY(bzero)
MEXITCOUNT
jmp *bzero_vector
ENTRY(generic_bzero)
pushl %edi
movl 8(%esp),%edi
@ -361,7 +362,7 @@ ENTRY(i686_pagezero)
1:
xorl %eax, %eax
repe
scasl
scasl
jnz 2f
popl %ebx
@ -446,10 +447,6 @@ ENTRY(bcopy)
MEXITCOUNT
jmp *bcopy_vector
ENTRY(ovbcopy)
MEXITCOUNT
jmp *ovbcopy_vector
/*
* generic_bcopy(src, dst, cnt)
* ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800

View File

@ -48,8 +48,8 @@
.globl bcopy_vector
bcopy_vector:
.long generic_bcopy
.globl bzero
bzero:
.globl bzero_vector
bzero_vector:
.long generic_bzero
.globl copyin_vector
copyin_vector:
@ -57,9 +57,6 @@ copyin_vector:
.globl copyout_vector
copyout_vector:
.long generic_copyout
.globl ovbcopy_vector
ovbcopy_vector:
.long generic_bcopy
#if defined(I586_CPU) && defined(DEV_NPX)
kernel_fpu_lock:
.byte 0xfe
@ -73,6 +70,10 @@ kernel_fpu_lock:
* void bzero(void *buf, u_int len)
*/
ENTRY(bzero)
MEXITCOUNT
jmp *bzero_vector
ENTRY(generic_bzero)
pushl %edi
movl 8(%esp),%edi
@ -361,7 +362,7 @@ ENTRY(i686_pagezero)
1:
xorl %eax, %eax
repe
scasl
scasl
jnz 2f
popl %ebx
@ -446,10 +447,6 @@ ENTRY(bcopy)
MEXITCOUNT
jmp *bcopy_vector
ENTRY(ovbcopy)
MEXITCOUNT
jmp *ovbcopy_vector
/*
* generic_bcopy(src, dst, cnt)
* ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800

View File

@ -36,12 +36,14 @@
* Miscellaneous machine-dependent declarations.
*/
extern long Maxmem;
extern u_int atdevbase; /* offset in virtual memory of ISA io mem */
extern void (*bcopy_vector)(const void *from, void *to, size_t len);
extern int busdma_swi_pending;
extern void (*bzero_vector)(void *buf, size_t len);
extern int (*copyin_vector)(const void *udaddr, void *kaddr, size_t len);
extern int (*copyout_vector)(const void *kaddr, void *udaddr, size_t len);
extern long Maxmem;
extern u_int atdevbase; /* offset in virtual memory of ISA io mem */
extern int busdma_swi_pending;
extern u_int cpu_exthigh;
extern u_int cpu_feature;
extern u_int cpu_fxsr;
@ -56,7 +58,6 @@ extern char kstack[];
extern int need_pre_dma_flush;
extern int need_post_dma_flush;
#endif
extern void (*ovbcopy_vector)(const void *from, void *to, size_t len);
extern char sigcode[];
extern int szsigcode;
#ifdef COMPAT_FREEBSD4

View File

@ -507,12 +507,10 @@ npx_attach(dev)
if (cpu_class == CPUCLASS_586 && npx_ex16 && npx_exists &&
timezero("i586_bzero()", i586_bzero) <
timezero("bzero()", bzero) * 4 / 5) {
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) {
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY))
bcopy_vector = i586_bcopy;
ovbcopy_vector = i586_bcopy;
}
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BZERO))
bzero = i586_bzero;
bzero_vector = i586_bzero;
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) {
copyin_vector = i586_copyin;
copyout_vector = i586_copyout;

View File

@ -563,7 +563,7 @@ printcpuinfo(void)
#if defined(I486_CPU)
case CPUCLASS_486:
printf("486");
bzero = i486_bzero;
bzero_vector = i486_bzero;
break;
#endif
#if defined(I586_CPU)

View File

@ -48,8 +48,8 @@
.globl bcopy_vector
bcopy_vector:
.long generic_bcopy
.globl bzero
bzero:
.globl bzero_vector
bzero_vector:
.long generic_bzero
.globl copyin_vector
copyin_vector:
@ -57,9 +57,6 @@ copyin_vector:
.globl copyout_vector
copyout_vector:
.long generic_copyout
.globl ovbcopy_vector
ovbcopy_vector:
.long generic_bcopy
#if defined(I586_CPU) && defined(DEV_NPX)
kernel_fpu_lock:
.byte 0xfe
@ -73,6 +70,10 @@ kernel_fpu_lock:
* void bzero(void *buf, u_int len)
*/
ENTRY(bzero)
MEXITCOUNT
jmp *bzero_vector
ENTRY(generic_bzero)
pushl %edi
movl 8(%esp),%edi
@ -361,7 +362,7 @@ ENTRY(i686_pagezero)
1:
xorl %eax, %eax
repe
scasl
scasl
jnz 2f
popl %ebx
@ -446,10 +447,6 @@ ENTRY(bcopy)
MEXITCOUNT
jmp *bcopy_vector
ENTRY(ovbcopy)
MEXITCOUNT
jmp *ovbcopy_vector
/*
* generic_bcopy(src, dst, cnt)
* ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800

View File

@ -36,12 +36,14 @@
* Miscellaneous machine-dependent declarations.
*/
extern long Maxmem;
extern u_int atdevbase; /* offset in virtual memory of ISA io mem */
extern void (*bcopy_vector)(const void *from, void *to, size_t len);
extern int busdma_swi_pending;
extern void (*bzero_vector)(void *buf, size_t len);
extern int (*copyin_vector)(const void *udaddr, void *kaddr, size_t len);
extern int (*copyout_vector)(const void *kaddr, void *udaddr, size_t len);
extern long Maxmem;
extern u_int atdevbase; /* offset in virtual memory of ISA io mem */
extern int busdma_swi_pending;
extern u_int cpu_exthigh;
extern u_int cpu_feature;
extern u_int cpu_fxsr;
@ -56,7 +58,6 @@ extern char kstack[];
extern int need_pre_dma_flush;
extern int need_post_dma_flush;
#endif
extern void (*ovbcopy_vector)(const void *from, void *to, size_t len);
extern char sigcode[];
extern int szsigcode;
#ifdef COMPAT_FREEBSD4

View File

@ -507,12 +507,10 @@ npx_attach(dev)
if (cpu_class == CPUCLASS_586 && npx_ex16 && npx_exists &&
timezero("i586_bzero()", i586_bzero) <
timezero("bzero()", bzero) * 4 / 5) {
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) {
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY))
bcopy_vector = i586_bcopy;
ovbcopy_vector = i586_bcopy;
}
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BZERO))
bzero = i586_bzero;
bzero_vector = i586_bzero;
if (!(flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) {
copyin_vector = i586_copyin;
copyout_vector = i586_copyout;

View File

@ -497,7 +497,6 @@ END(copyoutstr)
* Not the fastest bcopy in the world.
*/
ENTRY(bcopy, 3)
XENTRY(ovbcopy)
mov ret0=r0 // return zero for copy{in,out}
;;

View File

@ -497,7 +497,6 @@ END(copyoutstr)
* Not the fastest bcopy in the world.
*/
ENTRY(bcopy, 3)
XENTRY(ovbcopy)
mov ret0=r0 // return zero for copy{in,out}
;;

View File

@ -151,9 +151,3 @@ bcopy(const void *src0, void *dst0, size_t length)
memcpy(dst0, src0, length);
}
void
ovbcopy(const void *src0, void *dst0, size_t length)
{
memcpy(dst0, src0, length);
}

View File

@ -273,7 +273,6 @@ END(bcmp)
* void bcopy(const void *src, void *dst, size_t len)
*/
ENTRY(bcopy)
ENTRY(ovbcopy)
/*
* Check for overlap, and copy backwards if so.
*/

View File

@ -169,14 +169,9 @@ quad_t strtoq(const char *, char **, int);
u_quad_t strtouq(const char *, char **, int);
void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
#define ovbcopy(f, t, l) bcopy((f), (t), (l))
void bcopy(const void *from, void *to, size_t len);
void ovbcopy(const void *from, void *to, size_t len);
#ifdef __i386__
extern void (*bzero)(void *buf, size_t len);
#else
void bzero(void *buf, size_t len);
#endif
void *memcpy(void *to, const void *from, size_t len);