2007-10-03 Robert Millan * include/grub/i386/io.h: New file. Provides in*/out* inline declarations. * commands/i386/pc/play.c: Remove inb/outb declarations and #include instead. * term/i386/pc/serial.c: Likewise. * term/i386/pc/vga.c: Likewise. diff -Nur grub2/commands/i386/pc/play.c grub2.io/commands/i386/pc/play.c --- grub2/commands/i386/pc/play.c 2007-07-22 01:32:19.000000000 +0200 +++ grub2.io/commands/i386/pc/play.c 2007-10-03 15:09:45.000000000 +0200 @@ -27,25 +27,10 @@ #include #include #include +#include #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 diff -Nur grub2/DISTLIST grub2.io/DISTLIST --- grub2/DISTLIST 2007-08-28 12:16:49.000000000 +0200 +++ grub2.io/DISTLIST 2007-10-03 15:14:18.000000000 +0200 @@ -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 diff -Nur grub2/include/grub/i386/io.h grub2.io/include/grub/i386/io.h --- grub2/include/grub/i386/io.h 1970-01-01 01:00:00.000000000 +0100 +++ grub2.io/include/grub/i386/io.h 2007-10-03 15:11:45.000000000 +0200 @@ -0,0 +1,70 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1996,2000,2002,2007 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +/* Based on sys/io.h from GNU libc. */ + +#ifndef GRUB_IO_H +#define GRUB_IO_H 1 + +static __inline unsigned char +inb (unsigned short int port) +{ + unsigned char _v; + + __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned short int +inw (unsigned short int port) +{ + unsigned short _v; + + __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned int +inl (unsigned short int port) +{ + unsigned int _v; + + __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline void +outb (unsigned char value, unsigned short int port) +{ + __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); +} + +static __inline void +outw (unsigned short int value, unsigned short int port) +{ + __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port)); + +} + +static __inline void +outl (unsigned int value, unsigned short int port) +{ + __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port)); +} + +#endif /* _SYS_IO_H */ diff -Nur grub2/term/i386/pc/serial.c grub2.io/term/i386/pc/serial.c --- grub2/term/i386/pc/serial.c 2007-07-22 01:32:30.000000000 +0200 +++ grub2.io/term/i386/pc/serial.c 2007-10-03 15:09:45.000000000 +0200 @@ -25,6 +25,7 @@ #include #include #include +#include #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) diff -Nur grub2/term/i386/pc/vga.c grub2.io/term/i386/pc/vga.c --- grub2/term/i386/pc/vga.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2.io/term/i386/pc/vga.c 2007-10-03 15:09:45.000000000 +0200 @@ -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