Date: Sat, 13 Sep 1997 15:09:59 +1000 From: Bruce Evans <bde@zeta.org.au> To: freebsd-bugs@FreeBSD.ORG, j@uriah.heep.sax.de Subject: Re: kern/4486 Message-ID: <199709130509.PAA20233@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>The problem in question was IMHO non-existing adapter memory (the MDA
>frame buffer on an S3 card running in color mode). You can never be
>sure about misbehaving hardware in such cases. That's not only
I think you can be fairly sure about the behaviour of nonexistent ISA
memory.
>> Does the broken system also hang for 64-bit video accesses via the FPU?
>
>How would this be done?
Just access it via 64-bit FPU instructions.
Bruce
/*
* mmap standard 80x25 color text screen and write crud to first half of
* it using memcpy and several FPU versions of memcpy.
*/
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define MAPDEV "/dev/vga"
#define MAPSTART 0x18000
#define MAPEND 0x18800
#define MAPLEN (MAPEND - MAPSTART)
/*
* Simple (except for prefetch) copy through the FPU. Doesn't clip
* properly.
*/
static void
copy7(void *dst, const void *src, size_t len)
{
unsigned tmp;
asm volatile("
.align 4,0x90
1:
movl 64(%1),%3
nop
fildq 0(%1)
fildq 8(%1)
fildq 16(%1)
fildq 24(%1)
movl 96(%1),%3
nop
fildq 32(%1)
fildq 40(%1)
fildq 48(%1)
fildq 56(%1)
fxch %%st(1)
fistpq 48(%0)
fistpq 56(%0)
fistpq 40(%0)
fistpq 32(%0)
fistpq 24(%0)
fistpq 16(%0)
fistpq 8(%0)
fistpq 0(%0)
addl $64,%0
addl $64,%1
subl $64,%2
ja 1b"
: "=r" (dst), "=r" (src), "=r" (len), "=&r" (tmp)
: "0" (dst), "1" (src), "2" (len)
: "memory");
}
/* Essentially the current kernel i586_bcopy() (args swapped). */
static void
copyD(void *dst, const void *src, size_t len)
{
unsigned prefetch;
asm volatile("
.align 2,0x90
4:
pushl %2
cmpl $8192/2-256,%2
jbe 2f
movl $8192/2-256,%2
2:
subl %2,0(%%esp)
cmpl $256,%2
jb 5f
pushl %1
pushl %2
.align 2,0x90
3:
movl 0(%1),%3
movl 32(%1),%3
movl 64(%1),%3
movl 96(%1),%3
movl 128(%1),%3
movl 160(%1),%3
movl 192(%1),%3
movl 224(%1),%3
addl $256,%1
subl $256,%2
cmpl $256,%2
jae 3b
popl %2
popl %1
5:
.align 2,0x90
1:
fildq 0(%1)
fildq 8(%1)
fildq 16(%1)
fildq 24(%1)
fildq 32(%1)
fildq 40(%1)
fildq 48(%1)
fildq 56(%1)
fxch %%st(1)
fistpq 48(%0)
fistpq 56(%0)
fistpq 40(%0)
fistpq 32(%0)
fistpq 24(%0)
fistpq 16(%0)
fistpq 8(%0)
fistpq 0(%0)
addl $64,%1
addl $64,%0
subl $64,%2
cmpl $64,%2
jae 1b
popl %3
addl %3,%2
cmpl $64,%2
jae 4b
"
: "=r" (dst), "=r" (src), "=r" (len), "=&r" (prefetch)
: "0" (dst), "1" (src), "2" (len)
: "memory");
}
/* Essentially my new i586_bcopy() (args swapped). */
asm("
_copyF:
pushl %esi
pushl %edi
pushl %ebx
pushl %ebp
movl 16+4(%esp),%edi
movl 16+8(%esp),%esi
movl 16+12(%esp),%ecx
nop
testl $4,%edi
je 1f
movl 0(%esi),%edx
nop
movl %edx,0(%edi)
addl $4,%edi
addl $4,%esi
subl $4,%ecx
1:
movl $4096,%eax
movl $4096,%ebp
cmpl %ecx,%eax
jbe 2f
movl %ecx,%eax
movl %ecx,%ebp
andl $~0xff,%eax
je 3f
2:
movb 0(%esi),%dl
movb 32+4(%esi),%bl
movb 64(%esi),%dl
movb 96+4(%esi),%bl
movb 128(%esi),%dl
movb 160+4(%esi),%bl
movb 192(%esi),%dl
movb 224+4(%esi),%bl
addl $256,%esi
nop
subl $256,%eax
jne 2b
3:
movl %ebp,%eax
andl $~0x3f,%ebp
andl $0xc0,%eax
je 5f
4:
movb 0(%esi),%dl
movb 32+4(%esi),%bl
addl $64,%esi
nop
subl $64,%eax
jne 4b
5:
movl %ebp,%eax
subl %ebp,%esi
nop
jmp 7f
6:
fistpq -64+56(%edi)
fistpq -64+48(%edi)
fistpq -64+40(%edi)
fistpq -64+32(%edi)
fistpq -64+24(%edi)
fistpq -64+16(%edi)
fistpq -64+8(%edi)
fistpq -64+0(%edi)
7:
fildq 0(%esi)
fildq 8(%esi)
fildq 16(%esi)
fildq 24(%esi)
fildq 32(%esi)
fildq 40(%esi)
fildq 48(%esi)
fildq 56(%esi)
addl $64,%edi
addl $64,%esi
subl $64,%eax
jne 6b
fistpq -64+56(%edi)
fistpq -64+48(%edi)
fistpq -64+40(%edi)
fistpq -64+32(%edi)
fistpq -64+24(%edi)
fistpq -64+16(%edi)
fistpq -64+8(%edi)
fistpq -64+0(%edi)
subl %ebp,%ecx
nop
cmpl $64,%ecx
jae 1b
movl %ecx,%eax
nop
testl %ecx,%ecx
je 9f
movb 0(%esi),%dl
nop
andl $~0x7,%eax
je 6f
nop
nop
cmpl $32,%ecx
jbe 2f
movb 32(%esi),%dl
nop
nop
jmp 2f
1:
fistpq -8+0(%edi)
2:
fildq 0(%esi)
addl $8,%edi
addl $8,%esi
subl $8,%eax
jne 1b
fistpq -8+0(%edi)
3:
andl $7,%ecx
je 9f
nop
nop
6:
cmpl $4,%ecx
jb 4f
movl 0(%esi),%edx
movl %edx,0(%edi)
subl $4,%ecx
je 9f
addl $4,%edi
addl $4,%esi
4:
cmpl $2,%ecx
jb 5f
movw 0(%esi),%bx
movw %bx,0(%edi)
subl $2,%ecx
je 9f
addl $2,%edi
addl $2,%esi
5:
movb 0(%esi),%dl
movb %dl,0(%edi)
9:
popl %ebp
popl %ebx
popl %edi
popl %esi
ret
");
int
main(int argc, char **argv)
{
char crud[2048];
int fd;
int i;
caddr_t mm;
fd = open(MAPDEV, O_RDWR);
if (fd < 0) {
perror("open");
exit(1);
}
mm = mmap((caddr_t)0, (size_t)MAPLEN, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, fd, (off_t)MAPSTART);
if (mm == (caddr_t)-1) {
perror("mmap");
exit(1);
}
for (i = 0; i < sizeof crud; ++i)
crud[i] = random();
memcpy(mm, crud, sizeof crud);
#ifndef NO_FPU_COPIES
copy7(mm, crud, sizeof crud);
copyD(mm, crud, sizeof crud);
copyF(mm, crud, sizeof crud);
#endif
return (0);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709130509.PAA20233>
