diff options
author | Marc Espie <espie@cvs.openbsd.org> | 1999-01-31 14:56:02 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 1999-01-31 14:56:02 +0000 |
commit | c2ae597a496a66466fb1cd1fb02d5d450e3b06a8 (patch) | |
tree | 8da2c08f5a970c698efdcaa487d13cea5bc07a05 /sys | |
parent | fd89b8127a42f7f1e8364d5b93d3f95a23fe1f59 (diff) |
Fix clobbers so that GENERIC may compile with egcs.
Historically, the documentation of extended asm was lacking, namely you
should NOT specify the same register as an input, and a clobber.
If the register is clobbered, it should be specified as an output as well,
e.g., by linking input and output through the "number" notation.
(Beware of lvalues, some local variables needed...)
In older versions, up-to egcs1.1.1, the compiler did not even warn about
it, but it was liable to output bad code. Newer egcs are pickier and
simply refuse to swallow such code.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/include/bus.h | 188 | ||||
-rw-r--r-- | sys/arch/i386/include/pio.h | 35 | ||||
-rw-r--r-- | sys/arch/i386/isa/clock.c | 14 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/pciprobe.c | 6 | ||||
-rw-r--r-- | sys/dev/isa/seagate.c | 25 |
5 files changed, 136 insertions, 132 deletions
diff --git a/sys/arch/i386/include/bus.h b/sys/arch/i386/include/bus.h index df4405b5f54..3a2b312b9d3 100644 --- a/sys/arch/i386/include/bus.h +++ b/sys/arch/i386/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.13 1998/10/04 22:33:41 niklas Exp $ */ +/* $OpenBSD: bus.h,v 1.14 1999/01/31 14:56:01 espie Exp $ */ /* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */ /*- @@ -143,45 +143,45 @@ void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, #define bus_space_read_multi_1(t, h, o, a, c) do { \ if ((t) == I386_BUS_SPACE_IO) { \ insb((h) + (o), (a), (c)); \ - } else { \ + } else {void *_addr=(a); int _cnt=(c); \ __asm __volatile(" \ cld ; \ - 1: movb (%0),%%al ; \ + 1: movb (%2),%%al ; \ stosb ; \ loop 1b" : \ - : \ - "r" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_addr), "=c" (_cnt) : \ + "r" ((h) + (o)), "0" (_addr), "1" (_cnt) : \ + "%eax", "memory"); \ } \ } while (0) #define bus_space_read_multi_2(t, h, o, a, c) do { \ if ((t) == I386_BUS_SPACE_IO) { \ insw((h) + (o), (a), (c)); \ - } else { \ + } else {void *_addr=(a); int _cnt=(c); \ __asm __volatile(" \ cld ; \ - 1: movw (%0),%%ax ; \ + 1: movw (%2),%%ax ; \ stosw ; \ loop 1b" : \ - : \ - "r" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_addr), "=c" (_cnt) : \ + "r" ((h) + (o)), "0" (_addr), "1" (_cnt) : \ + "%eax", "memory"); \ } \ } while (0) #define bus_space_read_multi_4(t, h, o, a, c) do { \ if ((t) == I386_BUS_SPACE_IO) { \ insl((h) + (o), (a), (c)); \ - } else { \ + } else {void *_addr=(a); int _cnt=(c); \ __asm __volatile(" \ cld ; \ - 1: movl (%0),%%eax ; \ + 1: movl (%2),%%eax ; \ stosl ; \ loop 1b" : \ - : \ - "r" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_addr), "=c" (_cnt) : \ + "r" ((h) + (o)), "0" (_addr), "1" (_cnt) : \ + "%eax", "memory"); \ } \ } while (0) @@ -221,68 +221,71 @@ void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, */ #define bus_space_read_region_1(t, h, o, a, c) do { \ + int _cnt = (c); void *_addr = (a); int _port = (h)+(o); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ cld ; \ - 1: inb %w0,%%al ; \ + 1: inb %w2,%%al ; \ stosb ; \ - incl %0 ; \ + incl %2 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%edx", "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_addr), "=c" (_cnt), "=d" (_port) : \ + "0" (_addr), "1" (_cnt), "2" (_port) : \ + "%eax", "memory", "cc"); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ movsb" : \ - : \ - "S" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%esi", "%edi", "%ecx", "memory"); \ + "=D" (_addr), "=c" (_cnt), "=S" (_port) : \ + "0" (_addr), "1" (_cnt), "2" (_port) : \ + "memory", "cc"); \ } \ } while (0) #define bus_space_read_region_2(t, h, o, a, c) do { \ + int _cnt = (c); void *_addr = (a); int _port = (h)+(o); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ cld ; \ - 1: inw %w0,%%ax ; \ + 1: inw %w2,%%ax ; \ stosw ; \ - addl $2,%0 ; \ + addl $2,%2 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%edx", "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_addr), "=c" (_cnt), "=d" (_port) : \ + "0" (_addr), "1" (_cnt), "2" (_port) : \ + "%eax", "memory", "cc"); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ movsw" : \ - : \ - "S" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%esi", "%edi", "%ecx", "memory"); \ + "=D" (_addr), "=c" (_cnt), "=S" (_port) : \ + "0" (_addr), "1" (_cnt), "2" (_port) : \ + "memory", "cc"); \ } \ } while (0) #define bus_space_read_region_4(t, h, o, a, c) do { \ + int _cnt = (c); void *_addr = (a); int _port = (h)+(o); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ cld ; \ - 1: inl %w0,%%eax ; \ + 1: inl %w2,%%eax ; \ stosl ; \ - addl $4,%0 ; \ + addl $4,%2 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%edx", "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_addr), "=c" (_cnt), "=d" (_port) : \ + "0" (_addr), "1" (_cnt), "2" (_port) : \ + "%eax", "memory", "cc"); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ movsl" : \ - : \ - "S" ((h) + (o)), "D" ((a)), "c" ((c)) : \ - "%esi", "%edi", "%ecx", "memory"); \ + "=D" (_addr), "=c" (_cnt), "=S" (_port) : \ + "0" (_addr), "1" (_cnt), "2" (_port) : \ + "memory", "cc"); \ } \ } while (0) @@ -358,45 +361,45 @@ void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, #define bus_space_write_multi_1(t, h, o, a, c) do { \ if ((t) == I386_BUS_SPACE_IO) { \ outsb((h) + (o), (a), (c)); \ - } else { \ + } else {const void *_addr=(a); int _cnt=(c); \ __asm __volatile(" \ cld ; \ 1: lodsb ; \ - movb %%al,(%0) ; \ + movb %%al,(%2) ; \ loop 1b" : \ - : \ - "r" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%esi", "%ecx", "%eax"); \ + "=S" (_addr), "=c" (_cnt) : \ + "r" ((h) + (o)), "0" (_addr), "1" (_cnt) : \ + "%eax", "memory", "cc"); \ } \ } while (0) #define bus_space_write_multi_2(t, h, o, a, c) do { \ if ((t) == I386_BUS_SPACE_IO) { \ outsw((h) + (o), (a), (c)); \ - } else { \ + } else {const void *_addr=(a); int _cnt=(c); \ __asm __volatile(" \ cld ; \ 1: lodsw ; \ - movw %%ax,(%0) ; \ + movw %%ax,(%2) ; \ loop 1b" : \ - : \ - "r" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%esi", "%ecx", "%eax"); \ + "=S" (_addr), "=c" (_cnt) : \ + "r" ((h) + (o)), "0" (_addr), "1" (_cnt) : \ + "%eax", "memory", "cc"); \ } \ } while (0) #define bus_space_write_multi_4(t, h, o, a, c) do { \ if ((t) == I386_BUS_SPACE_IO) { \ outsl((h) + (o), (a), (c)); \ - } else { \ + } else {const void *_addr=(a); int _cnt=(c); \ __asm __volatile(" \ cld ; \ 1: lodsl ; \ - movl %%eax,(%0) ; \ + movl %%eax,(%2) ; \ loop 1b" : \ - : \ - "r" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%esi", "%ecx", "%eax"); \ + "=S" (_addr), "=c" (_cnt) : \ + "r" ((h) + (o)), "0" (_addr), "1" (_cnt) : \ + "%eax", "memory", "cc"); \ } \ } while (0) @@ -436,6 +439,7 @@ void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, */ #define bus_space_write_region_1(t, h, o, a, c) do { \ + int _port = (h)+(o); void *_addr=(a); int _cnt=(c); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ cld ; \ @@ -443,21 +447,22 @@ void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, outb %%al,%w0 ; \ incl %0 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%edx", "%esi", "%ecx", "%eax", "memory"); \ + "=d" (_port), "=S" (_addr), "=c" (_cnt) : \ + "0" (_port), "1" (_addr), "2" (_cnt) : \ + "%eax", "memory", "cc"); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ movsb" : \ - : \ - "D" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%edi", "%esi", "%ecx", "memory"); \ + "=D" (_port), "=S" (_addr), "=c" (_cnt) : \ + "0" (_port), "1" (_addr), "2" (_cnt) : \ + "memory", "cc"); \ } \ } while (0) #define bus_space_write_region_2(t, h, o, a, c) do { \ + int _port = (h)+(o); void *_addr=(a); int _cnt=(c); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ cld ; \ @@ -465,21 +470,22 @@ void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, outw %%ax,%w0 ; \ addl $2,%0 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%edx", "%esi", "%ecx", "%eax", "memory"); \ + "=d" (_port), "=S" (_addr), "=c" (_cnt) : \ + "0" (_port), "1" (_addr), "2" (_cnt) : \ + "%eax", "memory", "cc"); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ movsw" : \ - : \ - "D" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%edi", "%esi", "%ecx", "memory"); \ + "=D" (_port), "=S" (_addr), "=c" (_cnt) : \ + "0" (_port), "1" (_addr), "2" (_cnt) : \ + "memory", "cc"); \ } \ } while (0) #define bus_space_write_region_4(t, h, o, a, c) do { \ + int _port = (h)+(o); void *_addr=(a); int _cnt=(c); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ cld ; \ @@ -487,17 +493,17 @@ void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, outl %%eax,%w0 ; \ addl $4,%0 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%edx", "%esi", "%ecx", "%eax", "memory"); \ + "=d" (_port), "=S" (_addr), "=c" (_cnt) : \ + "0" (_port), "1" (_addr), "2" (_cnt) : \ + "%eax", "memory", "cc"); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ movsl" : \ - : \ - "D" ((h) + (o)), "S" ((a)), "c" ((c)) : \ - "%edi", "%esi", "%ecx", "memory"); \ + "=D" (_port), "=S" (_addr), "=c" (_cnt) : \ + "0" (_port), "1" (_addr), "2" (_cnt) : \ + "memory", "cc"); \ } \ } while (0) @@ -612,62 +618,62 @@ void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, */ #define bus_space_set_region_1(t, h, o, v, c) do { \ + int _port = (h)+(o); int _cnt = (c); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ 1: outb %%al,%w0 ; \ incl %0 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "c" ((c)), "a" ((v)) : \ - "%edx", "%ecx", "%eax"); \ + "=d" (_port), "=c" (_cnt) : \ + "0" (_port), "1" (_cnt), "a" ((v))); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ stosb" : \ - : \ - "D" ((h) + (o)), "c" ((c)), "a" ((v)) : \ - "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_port), "=c" (_cnt) : \ + "0" (_port), "1" (_cnt), "a" ((v)) : \ + "memory"); \ } \ } while (0) #define bus_space_set_region_2(t, h, o, v, c) do { \ + int _port = (h)+(o); int _cnt = (c); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ 1: outw %%ax,%w0 ; \ addl $2, %0 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "c" ((c)), "a" ((v)) : \ - "%edx", "%ecx", "%eax"); \ + "=d" (_port), "=c" (_cnt) : \ + "0" (_port), "1" (_cnt), "a" ((v))); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ stosw" : \ - : \ - "D" ((h) + (o)), "c" ((c)), "a" ((v)) : \ - "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_port), "=c" (_cnt) : \ + "0" (_port), "1" (_cnt), "a" ((v)) : \ + "memory"); \ } \ } while (0) #define bus_space_set_region_4(t, h, o, v, c) do { \ + int _port = (h)+(o); int _cnt = (c); \ if ((t) == I386_BUS_SPACE_IO) { \ __asm __volatile(" \ 1: outl %%eax,%w0 ; \ addl $4, %0 ; \ loop 1b" : \ - : \ - "d" ((h) + (o)), "c" ((c)), "a" ((v)) : \ - "%edx", "%ecx", "%eax"); \ + "=d" (_port), "=c" (_cnt) : \ + "0" (_port), "1" (_cnt), "a" ((v))); \ } else { \ __asm __volatile(" \ cld ; \ repne ; \ stosl" : \ - : \ - "D" ((h) + (o)), "c" ((c)), "a" ((v)) : \ - "%edi", "%ecx", "%eax", "memory"); \ + "=D" (_port), "=c" (_cnt) : \ + "0" (_port), "1" (_cnt), "a" ((v)) : \ + "memory"); \ } \ } while (0) diff --git a/sys/arch/i386/include/pio.h b/sys/arch/i386/include/pio.h index 47ee837e109..eaabb04b296 100644 --- a/sys/arch/i386/include/pio.h +++ b/sys/arch/i386/include/pio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pio.h,v 1.5 1997/11/10 23:40:45 niklas Exp $ */ +/* $OpenBSD: pio.h,v 1.6 1999/01/31 14:56:01 espie Exp $ */ /* $NetBSD: pio.h,v 1.13 1996/03/08 20:15:23 cgd Exp $ */ /* @@ -77,9 +77,9 @@ static __inline void insb(int port, void *addr, int cnt) { __asm __volatile("cld\n\trepne\n\tinsb" : - : - "d" (port), "D" (addr), "c" (cnt) : - "%edi", "%ecx", "memory"); + "=D" (addr), "=c" (cnt) : + "d" (port), "0" (addr), "1" (cnt) : + "memory"); } #define inw(port) \ @@ -105,9 +105,9 @@ static __inline void insw(int port, void *addr, int cnt) { __asm __volatile("cld\n\trepne\n\tinsw" : - : - "d" (port), "D" (addr), "c" (cnt) : - "%edi", "%ecx", "memory"); + "=D" (addr), "=c" (cnt) : + "d" (port), "0" (addr), "1" (cnt) : + "memory"); } #define inl(port) \ @@ -133,9 +133,9 @@ static __inline void insl(int port, void *addr, int cnt) { __asm __volatile("cld\n\trepne\n\tinsl" : - : - "d" (port), "D" (addr), "c" (cnt) : - "%edi", "%ecx", "memory"); + "=D" (addr), "=c" (cnt) : + "d" (port), "0" (addr), "1" (cnt) : + "memory"); } #define outb(port, data) \ @@ -157,9 +157,8 @@ static __inline void outsb(int port, const void *addr, int cnt) { __asm __volatile("cld\n\trepne\n\toutsb" : - : - "d" (port), "S" (addr), "c" (cnt) : - "%esi", "%ecx"); + "=S" (addr), "=c" (cnt) : + "d" (port), "0" (addr), "1" (cnt)); } #define outw(port, data) \ @@ -181,9 +180,8 @@ static __inline void outsw(int port, const void *addr, int cnt) { __asm __volatile("cld\n\trepne\n\toutsw" : - : - "d" (port), "S" (addr), "c" (cnt) : - "%esi", "%ecx"); + "=S" (addr), "=c" (cnt) : + "d" (port), "0" (addr), "1" (cnt)); } #define outl(port, data) \ @@ -205,9 +203,8 @@ static __inline void outsl(int port, const void *addr, int cnt) { __asm __volatile("cld\n\trepne\n\toutsl" : - : - "d" (port), "S" (addr), "c" (cnt) : - "%esi", "%ecx"); + "=S" (addr), "=c" (cnt) : + "d" (port), "0" (addr), "1" (cnt)); } #endif /* _I386_PIO_H_ */ diff --git a/sys/arch/i386/isa/clock.c b/sys/arch/i386/isa/clock.c index 4c1beee01f6..12cc6bdf252 100644 --- a/sys/arch/i386/isa/clock.c +++ b/sys/arch/i386/isa/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.18 1999/01/13 07:26:00 niklas Exp $ */ +/* $OpenBSD: clock.c,v 1.19 1999/01/31 14:56:01 espie Exp $ */ /* $NetBSD: clock.c,v 1.39 1996/05/12 23:11:54 mycroft Exp $ */ /*- @@ -262,14 +262,10 @@ delay(n) n -= 5; if (n < 0) return; - {register int m; - __asm __volatile("mul %3" - : "=a" (n), "=d" (m) - : "0" (n), "r" (TIMER_FREQ)); - __asm __volatile("div %3" - : "=a" (n) - : "0" (n), "d" (m), "r" (1000000) - : "%edx");} + __asm __volatile("mul %2\n\tdiv %3" + : "=a" (n) + : "0" (n), "r" (TIMER_FREQ), "r" (1000000) + : "%edx", "cc"); #else /* * Calculate ((n * TIMER_FREQ) / 1e6) without using floating point and diff --git a/sys/arch/i386/stand/libsa/pciprobe.c b/sys/arch/i386/stand/libsa/pciprobe.c index 7ba6d2cda55..bef46384944 100644 --- a/sys/arch/i386/stand/libsa/pciprobe.c +++ b/sys/arch/i386/stand/libsa/pciprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pciprobe.c,v 1.1 1998/02/24 22:07:46 weingart Exp $ */ +/* $OpenBSD: pciprobe.c,v 1.2 1999/01/31 14:56:01 espie Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -50,8 +50,8 @@ pciprobe() __asm __volatile(DOINT(0x1A) ";shll $8,%2; setc %b2" : "=a" (hw_chars), "=b" (rev), "=c" (rc), "=d" (sig), "=D" (entry32) - : "0" (0xB101), "D" (0x0) - : "cc", "eax", "ebx", "ecx", "edx"); + : "0" (0xB101), "4" (0x0) + : "cc"); if (rc & 0xff00 || hw_chars & 0xff00) return; diff --git a/sys/dev/isa/seagate.c b/sys/dev/isa/seagate.c index 4d7d9755480..fcba075b106 100644 --- a/sys/dev/isa/seagate.c +++ b/sys/dev/isa/seagate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: seagate.c,v 1.12 1999/01/07 06:14:49 niklas Exp $ */ +/* $OpenBSD: seagate.c,v 1.13 1999/01/31 14:56:01 espie Exp $ */ /* * ST01/02, Future Domain TMC-885, TMC-950 SCSI driver @@ -1304,33 +1304,38 @@ sea_information_transfer(sea) if ((tmp & PH_MASK) != phase) break; if (!(phase & STAT_IO)) { + int block = BLOCK_SIZE; + void *a = sea->maddr_dr; #ifdef SEA_ASSEMBLER asm("shr $2, %%ecx\n\t\ cld\n\t\ rep\n\t\ movsl" : - "=S" (scb->data) : + "=S" (scb->data), + "=c" (block) , + "=D" (a) : "0" (scb->data), - "D" (sea->maddr_dr), - "c" (BLOCK_SIZE) : - "%ecx", "%edi"); + "2" (a), + "1" (block) ); #else for (count = 0; count < BLOCK_SIZE; count++) DATA = *(scb->data++); #endif - } else { + } else { + int block = BLOCK_SIZE; + void *a = sea->maddr_dr; #ifdef SEA_ASSEMBLER asm("shr $2, %%ecx\n\t\ cld\n\t\ rep\n\t\ movsl" : - "=D" (scb->data) : - "S" (sea->maddr_dr), + "=D" (scb->data), "=c" (block) , + "=S" (a) : "0" (scb->data), - "c" (BLOCK_SIZE) : - "%ecx", "%esi"); + "2" (a) , + "1" (block) ); #else for (count = 0; count < BLOCK_SIZE; |