The assembler needs to know the instruction size.
authorcoderain <coderain@sdf.org>
Sat, 1 Sep 2018 21:16:47 +0000 (23:16 +0200)
committercoderain <coderain@sdf.org>
Sat, 1 Sep 2018 21:16:47 +0000 (23:16 +0200)
kernel/include/cpu.h

index d6fc1f2c323c5cbb81c34ea3182fffef1a0da0f7..7619e76b215ae74985d96576814b7c2a04824e4d 100644 (file)
@@ -66,7 +66,7 @@ enum
 
 typedef word_t port_t;
 
-#define IO_PORT_FUNCTIONS(type)                                         \
+#define IO_PORT_FUNCTIONS(type, prefix)                                 \
     static inline type##_t cpu_read_port_##type(port_t port)            \
     {                                                                   \
         type##_t value;                                                 \
@@ -82,7 +82,7 @@ typedef word_t port_t;
     static inline void cpu_read_port_buffer_##type(port_t port, type##_t *buffer, size_t size) \
     {                                                                   \
         __asm__ volatile("cld\n"                                        \
-                         "rep; ins\n"                                   \
+                         "rep; ins" prefix "\n"                         \
                          :"+D"(buffer), "+c"(size)                      \
                          : "d"(port)                                    \
                          : "cc");                                       \
@@ -91,15 +91,15 @@ typedef word_t port_t;
     static inline void cpu_write_port_buffer_##type(port_t port, const type##_t *buffer, size_t size) \
     {                                                                   \
         __asm__ volatile("cld\n"                                        \
-                       "rep; outs\n"                                    \
-                       : "+S"(buffer), "+c"(size)                       \
-                       : "d"(port)                                      \
-                       : "cc");                                         \
+                         "rep; outs " prefix "\n"                       \
+                         : "+S"(buffer), "+c"(size)                     \
+                         : "d"(port)                                    \
+                         : "cc");                                       \
     }
 
-IO_PORT_FUNCTIONS(byte)
-IO_PORT_FUNCTIONS(word)
-IO_PORT_FUNCTIONS(dword)
+IO_PORT_FUNCTIONS(byte, "b")
+IO_PORT_FUNCTIONS(word, "w")
+IO_PORT_FUNCTIONS(dword, "l")
 
 static inline uintptr_t cpu_read_master_control_register(void)
 {