Skip to contentSkip to conversation

io.h (inb/outb/etc)

PATCH In review Robert Millan 1 participant 2 messages Oct 3, 2007 – Oct 5, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io.h (inb/outb/etc)

Hi!

There seems to be a few duplicated inb/outb inline declarations around different parts of GRUB. New code that makes use of them has to implement them again, etc. I'd like to add this patch to get them from <grub/cpu/io.h> instead.

Any comments?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)

2007-10-03 Robert Millan <[email protected]>

* include/grub/i386/io.h: New file. Provides in*/out* inline declarations.
* commands/i386/pc/play.c: Remove inb/outb declarations and #include <grub/cpu/io.h> instead.
* term/i386/pc/serial.c: Likewise.
* term/i386/pc/vga.c: Likewise.

commands/i386/pc/play.c +1 -16
diff -Nur grub2/commands/i386/pc/play.c grub2.io/commands/i386/pc/play.c
@@ -27,25 +27,10 @@
 #include <grub/term.h>
 #include <grub/misc.h>
 #include <grub/machine/time.h>
+#include <grub/cpu/io.h>
 
 #define BASE_TEMPO 120
 
-/* Read a byte from a port.  */
-static inline unsigned char
-inb (unsigned short port)
-{
-  unsigned char value;
-  asm volatile ("inb    %w1, %0" : "=a" (value) : "Nd" (port));
-  return value;
-}
-
-/* Write a byte to a port.  */
-static inline void
-outb (unsigned short port, unsigned char value)
-{
-  asm volatile ("outb   %b0, %w1" : : "a" (value), "Nd" (port));
-}
-
 /* The speaker port.  */
 #define SPEAKER			0x61
 
DISTLIST +1 -0
diff -Nur grub2/DISTLIST grub2.io/DISTLIST
@@ -142,6 +142,7 @@
 include/grub/i386/efi/kernel.h
 include/grub/i386/efi/loader.h
 include/grub/i386/efi/time.h
+include/grub/i386/io.h
 include/grub/i386/pc/biosdisk.h
 include/grub/i386/pc/boot.h
 include/grub/i386/pc/chainloader.h
include/grub/i386/io.h +70 -0

70 lines not on this page · raw message

term/i386/pc/serial.c +1 -20
diff -Nur grub2/term/i386/pc/serial.c grub2.io/term/i386/pc/serial.c
@@ -25,6 +25,7 @@
 #include <grub/normal.h>
 #include <grub/arg.h>
 #include <grub/terminfo.h>
+#include <grub/cpu/io.h>
 
 #define TEXT_WIDTH	80
 #define TEXT_HEIGHT	25
@@ -62,26 +63,6 @@
 /* Serial port settings.  */
 static struct serial_port serial_settings;
 
-/* Read a byte from a port.  */
-static inline unsigned char
-inb (const unsigned short port)
-{
-  unsigned char value;
-
-  asm volatile ("inb    %w1, %0" : "=a" (value) : "Nd" (port));
-  asm volatile ("outb   %%al, $0x80" : : );
-
-  return value;
-}
-
-/* Write a byte to a port.  */
-static inline void
-outb (const unsigned short port, const unsigned char value)
-{
-  asm volatile ("outb   %b0, %w1" : : "a" (value), "Nd" (port));
-  asm volatile ("outb   %%al, $0x80" : : );
-}
-
 /* Return the port number for the UNITth serial device.  */
 static inline unsigned short
 serial_hw_get_port (const unsigned short unit)
term/i386/pc/vga.c +0 -20
diff -Nur grub2/term/i386/pc/vga.c grub2.io/term/i386/pc/vga.c
@@ -66,26 +66,6 @@
 static unsigned char saved_map_mask;
 static int page = 0;
 
-/* Read a byte from a port.  */
-static inline unsigned char
-inb (unsigned short port)
-{
-  unsigned char value;
-
-  asm volatile ("inb    %w1, %0" : "=a" (value) : "Nd" (port));
-  asm volatile ("outb   %%al, $0x80" : : );
-  
-  return value;
-}
-
-/* Write a byte to a port.  */
-static inline void
-outb (unsigned short port, unsigned char value)
-{
-  asm volatile ("outb   %b0, %w1" : : "a" (value), "Nd" (port));
-  asm volatile ("outb   %%al, $0x80" : : );
-}
-
 #define SEQUENCER_ADDR_PORT	0x3C4
 #define SEQUENCER_DATA_PORT	0x3C5
 #define MAP_MASK_REGISTER	0x02
#1 lore raw

Comitted after some changes suggested by Marco on IRC.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)