projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rewrite the I/O port code.
[pintos-anon]
/
src
/
threads
/
io.h
diff --git
a/src/threads/io.h
b/src/threads/io.h
index 39a135dcc23e46abfa21551a1b8f1c13753a9cf5..30d52da046ee2faa2d0caac142f67a3730cb9c5f 100644
(file)
--- a/
src/threads/io.h
+++ b/
src/threads/io.h
@@
-1,5
+1,5
@@
-#ifndef
HEADER
_IO_H
-#define
HEADER_IO_H 1
+#ifndef
THREADS
_IO_H
+#define
THREADS_IO_H
#include <stddef.h>
#include <stdint.h>
#include <stddef.h>
#include <stdint.h>
@@
-8,8
+8,9
@@
static inline uint8_t
inb (uint16_t port)
{
static inline uint8_t
inb (uint16_t port)
{
+ /* See [IA32-v2a] "IN". */
uint8_t data;
uint8_t data;
- asm volatile ("inb %w1,
%0" : "=a" (data) : "
d" (port));
+ asm volatile ("inb %w1,
%b0" : "=a" (data) : "N
d" (port));
return data;
}
return data;
}
@@
-18,10
+19,8
@@
inb (uint16_t port)
static inline void
insb (uint16_t port, void *addr, size_t cnt)
{
static inline void
insb (uint16_t port, void *addr, size_t cnt)
{
- asm volatile ("cld; repne; insb"
- : "=D" (addr), "=c" (cnt)
- : "d" (port), "0" (addr), "1" (cnt)
- : "memory", "cc");
+ /* See [IA32-v2a] "INS". */
+ asm volatile ("rep insb" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
}
/* Reads and returns 16 bits from PORT. */
}
/* Reads and returns 16 bits from PORT. */
@@
-29,7
+28,8
@@
static inline uint16_t
inw (uint16_t port)
{
uint16_t data;
inw (uint16_t port)
{
uint16_t data;
- asm volatile ("inw %w1,%0" : "=a" (data) : "d" (port));
+ /* See [IA32-v2a] "IN". */
+ asm volatile ("inw %w1, %w0" : "=a" (data) : "Nd" (port));
return data;
}
return data;
}
@@
-38,18
+38,17
@@
inw (uint16_t port)
static inline void
insw (uint16_t port, void *addr, size_t cnt)
{
static inline void
insw (uint16_t port, void *addr, size_t cnt)
{
- asm volatile ("cld; repne; insw"
- : "=D" (addr), "=c" (cnt)
- : "d" (port), "0" (addr), "1" (cnt)
- : "memory", "cc");
+ /* See [IA32-v2a] "INS". */
+ asm volatile ("rep insw" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
}
/* Reads and returns 32 bits from PORT. */
static inline uint32_t
inl (uint16_t port)
{
}
/* Reads and returns 32 bits from PORT. */
static inline uint32_t
inl (uint16_t port)
{
+ /* See [IA32-v2a] "IN". */
uint32_t data;
uint32_t data;
- asm volatile ("inl %w1,
%0" : "=a" (data) : "
d" (port));
+ asm volatile ("inl %w1,
%0" : "=a" (data) : "N
d" (port));
return data;
}
return data;
}
@@
-58,17
+57,16
@@
inl (uint16_t port)
static inline void
insl (uint16_t port, void *addr, size_t cnt)
{
static inline void
insl (uint16_t port, void *addr, size_t cnt)
{
- asm volatile ("cld; repne; insl"
- : "=D" (addr), "=c" (cnt)
- : "d" (port), "0" (addr), "1" (cnt)
- : "memory", "cc");
+ /* See [IA32-v2a] "INS". */
+ asm volatile ("rep insl" : "+D" (addr), "+c" (cnt) : "d" (port) : "memory");
}
/* Writes byte DATA to PORT. */
static inline void
outb (uint16_t port, uint8_t data)
{
}
/* Writes byte DATA to PORT. */
static inline void
outb (uint16_t port, uint8_t data)
{
- asm volatile ("outb %0,%w1" : : "a" (data), "d" (port));
+ /* See [IA32-v2b] "OUT". */
+ asm volatile ("outb %b0, %w1" : : "a" (data), "Nd" (port));
}
/* Writes to PORT each byte of data in the CNT-byte buffer
}
/* Writes to PORT each byte of data in the CNT-byte buffer
@@
-76,17
+74,16
@@
outb (uint16_t port, uint8_t data)
static inline void
outsb (uint16_t port, const void *addr, size_t cnt)
{
static inline void
outsb (uint16_t port, const void *addr, size_t cnt)
{
- asm volatile ("cld; repne; outsb"
- : "=S" (addr), "=c" (cnt)
- : "d" (port), "0" (addr), "1" (cnt)
- : "cc");
+ /* See [IA32-v2b] "OUTS". */
+ asm volatile ("rep outsb" : "+S" (addr), "+c" (cnt) : "d" (port));
}
/* Writes the 16-bit DATA to PORT. */
static inline void
outw (uint16_t port, uint16_t data)
{
}
/* Writes the 16-bit DATA to PORT. */
static inline void
outw (uint16_t port, uint16_t data)
{
- asm volatile ("outw %0,%w1" : : "a" (data), "d" (port));
+ /* See [IA32-v2b] "OUT". */
+ asm volatile ("outw %w0, %w1" : : "a" (data), "Nd" (port));
}
/* Writes to PORT each 16-bit unit (halfword) of data in the
}
/* Writes to PORT each 16-bit unit (halfword) of data in the
@@
-94,17
+91,16
@@
outw (uint16_t port, uint16_t data)
static inline void
outsw (uint16_t port, const void *addr, size_t cnt)
{
static inline void
outsw (uint16_t port, const void *addr, size_t cnt)
{
- asm volatile ("cld; repne; outsw"
- : "=S" (addr), "=c" (cnt)
- : "d" (port), "0" (addr), "1" (cnt)
- : "cc");
+ /* See [IA32-v2b] "OUTS". */
+ asm volatile ("rep outsw" : "+S" (addr), "+c" (cnt) : "d" (port));
}
/* Writes the 32-bit DATA to PORT. */
static inline void
outl (uint16_t port, uint32_t data)
{
}
/* Writes the 32-bit DATA to PORT. */
static inline void
outl (uint16_t port, uint32_t data)
{
- asm volatile ("outl %0,%w1" : : "a" (data), "d" (port));
+ /* See [IA32-v2b] "OUT". */
+ asm volatile ("outl %0, %w1" : : "a" (data), "Nd" (port));
}
/* Writes to PORT each 32-bit unit (word) of data in the CNT-word
}
/* Writes to PORT each 32-bit unit (word) of data in the CNT-word
@@
-112,10
+108,8
@@
outl (uint16_t port, uint32_t data)
static inline void
outsl (uint16_t port, const void *addr, size_t cnt)
{
static inline void
outsl (uint16_t port, const void *addr, size_t cnt)
{
- asm volatile ("cld; repne; outsl"
- : "=S" (addr), "=c" (cnt)
- : "d" (port), "0" (addr), "1" (cnt)
- : "cc");
+ /* See [IA32-v2b] "OUTS". */
+ asm volatile ("rep outsl" : "+S" (addr), "+c" (cnt) : "d" (port));
}
}
-#endif /* io.h */
+#endif /*
threads/
io.h */