All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: Matthew Garrett <mjg@redhat.com>
Subject: Re: [PATCH 1/4] Add PCI protocols
Date: Wed, 08 Feb 2012 20:51:01 +0100	[thread overview]
Message-ID: <4F32D225.6000106@gmail.com> (raw)
In-Reply-To: <1328719918-4789-2-git-send-email-mjg@redhat.com>

Go ahead.
As a note: it may be useful for ia64 in future.
On 08.02.2012 17:51, Matthew Garrett wrote:
> There's various UEFI protocols for handling PCI devices. Add support for them.
> ---
>   ChangeLog              |    4 +
>   include/grub/efi/pci.h |  319 ++++++++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 323 insertions(+), 0 deletions(-)
>   create mode 100644 include/grub/efi/pci.h
>
> diff --git a/ChangeLog b/ChangeLog
> index ede7f8e..ca07786 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,7 @@
> +2012-02-08  Matthew Garrett<mjg@redhat.com>
> +
> +	* include/grub/efi/pci.h: New file to define EFI PCI protocols.
> +
>   2012-02-07  Vladimir Serbinenko<phcoder@gmail.com>
>
>   	* grub-core/lib/i386/relocator16.S: Revert moving A20 code into PM
> diff --git a/include/grub/efi/pci.h b/include/grub/efi/pci.h
> new file mode 100644
> index 0000000..b172455
> --- /dev/null
> +++ b/include/grub/efi/pci.h
> @@ -0,0 +1,319 @@
> +/*
> + *  GRUB  --  GRand Unified Bootloader
> + *  Copyright (C) 2006,2007,2008  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<http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef GRUB_EFI_PCI_HEADER
> +#define GRUB_EFI_PCI_HEADER	1
> +
> +#include<grub/symbol.h>
> +
> +#define GRUB_EFI_PCI_IO_GUID \
> +  { 0x4cf5b200, 0x68b8, 0x4ca5, { 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a }}
> +
> +#define GRUB_EFI_PCI_ROOT_IO_GUID \
> +  { 0x2F707EBB, 0x4A1A, 0x11d4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}
> +
> +typedef enum
> +  {
> +    GRUB_EFI_PCI_IO_WIDTH_UINT8,
> +    GRUB_EFI_PCI_IO_WIDTH_UINT16,
> +    GRUB_EFI_PCI_IO_WIDTH_UINT32,
> +    GRUB_EFI_PCI_IO_WIDTH_UINT64,
> +    GRUB_EFI_PCI_IO_WIDTH_FIFO_UINT8,
> +    GRUB_EFI_PCI_IO_WIDTH_FIFO_UINT16,
> +    GRUB_EFI_PCI_IO_WIDTH_FIFO_UINT32,
> +    GRUB_EFI_PCI_IO_WIDTH_FIFO_UINT64,
> +    GRUB_EFI_PCI_IO_WIDTH_FILL_UINT8,
> +    GRUB_EFI_PCI_IO_WIDTH_FILL_UINT16,
> +    GRUB_EFI_PCI_IO_WIDTH_FILL_UINT32,
> +    GRUB_EFI_PCI_IO_WIDTH_FILL_UINT64,
> +    GRUB_EFI_PCI_IO_WIDTH_MAXIMUM,
> +  }
> +  grub_efi_pci_io_width_t;
> +
> +struct grub_efi_pci_io;
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_mem_t) (struct grub_efi_pci_io *this,
> +			  grub_efi_pci_io_width_t width,
> +			  grub_efi_uint8_t bar_index,
> +			  grub_efi_uint64_t offset,
> +			  grub_efi_uintn_t count,
> +			  void *buffer);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_config_t) (struct grub_efi_pci_io *this,
> +			     grub_efi_pci_io_width_t width,
> +			     grub_efi_uint32_t offset,
> +			     grub_efi_uintn_t count,
> +			     void *buffer);
> +typedef struct
> +{
> +  grub_efi_pci_io_mem_t read;
> +  grub_efi_pci_io_mem_t write;
> +} grub_efi_pci_io_access_t;
> +
> +typedef struct
> +{
> +  grub_efi_pci_io_config_t read;
> +  grub_efi_pci_io_config_t write;
> +} grub_efi_pci_io_config_access_t;
> +
> +typedef enum
> +  {
> +    GRUB_EFI_PCI_IO_OPERATION_BUS_MASTER_READ,
> +    GRUB_EFI_PCI_IO_OPERATION_BUS_MASTER_WRITE,
> +    GRUB_EFI_PCI_IO_OPERATION_BUS_MASTER_COMMON_BUFFER,
> +    GRUB_EFI_PCI_IO_OPERATION_BUS_MASTER_MAXIMUM
> +  }
> +  grub_efi_pci_io_operation_t;
> +
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_ISA_IO               0x0002
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO       0x0004
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY           0x0008
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_IO               0x0010
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO       0x0020
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO     0x0040
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_IO                   0x0100
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_MEMORY               0x0200
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_BUS_MASTER           0x0400
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED        0x0800
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE       0x1000
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE      0x2000
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM         0x4000
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE   0x8000
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_ISA_IO_16            0x10000
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16    0x20000
> +#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_IO_16            0x40000
> +
> +typedef enum
> +  {
> +    GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_GET,
> +    GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_SET,
> +    GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_ENABLE,
> +    GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_DISABLE,
> +    GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_SUPPORTED,
> +    GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_MAXIMUM
> +  }
> +  grub_efi_pci_io_attribute_operation_t;
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_poll_io_mem_t) (struct grub_efi_pci_io *this,
> +				  grub_efi_pci_io_width_t  width,
> +				  grub_efi_uint8_t bar_ndex,
> +				  grub_efi_uint64_t offset,
> +				  grub_efi_uint64_t mask,
> +				  grub_efi_uint64_t value,
> +				  grub_efi_uint64_t delay,
> +				  grub_efi_uint64_t *result);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_copy_mem_t) (struct grub_efi_pci_io *this,
> +			       grub_efi_pci_io_width_t width,
> +			       grub_efi_uint8_t dest_bar_index,
> +			       grub_efi_uint64_t dest_offset,
> +			       grub_efi_uint8_t src_bar_index,
> +			       grub_efi_uint64_t src_offset,
> +			       grub_efi_uintn_t count);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_map_t) (struct grub_efi_pci_io *this,
> +			  grub_efi_pci_io_operation_t operation,
> +			  void *host_address,
> +			  grub_efi_uintn_t *number_of_bytes,
> +			  grub_efi_uint64_t *device_address,
> +			  void **mapping);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_unmap_t) (struct grub_efi_pci_io *this,
> +			    void *mapping);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_allocate_buffer_t) (struct grub_efi_pci_io *this,
> +				      grub_efi_allocate_type_t type,
> +				      grub_efi_memory_type_t memory_type,
> +				      grub_efi_uintn_t pages,
> +				      void **host_address,
> +				      grub_efi_uint64_t attributes);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_free_buffer_t) (struct grub_efi_pci_io *this,
> +				  grub_efi_allocate_type_t type,
> +				  grub_efi_memory_type_t memory_type,
> +				  grub_efi_uintn_t pages,
> +				  void **host_address,
> +				  grub_efi_uint64_t attributes);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_flush_t) (struct grub_efi_pci_io *this);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_get_location_t) (struct grub_efi_pci_io *this,
> +				   grub_efi_uintn_t *segment_number,
> +				   grub_efi_uintn_t *bus_number,
> +				   grub_efi_uintn_t *device_number,
> +				   grub_efi_uintn_t *function_number);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_attributes_t) (struct grub_efi_pci_io *this,
> +				 grub_efi_pci_io_attribute_operation_t operation,
> +				 grub_efi_uint64_t attributes,
> +				 grub_efi_uint64_t *result);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_get_bar_attributes_t) (struct grub_efi_pci_io *this,
> +					 grub_efi_uint8_t bar_index,
> +					 grub_efi_uint64_t *supports,
> +					 void **resources);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_io_set_bar_attributes_t) (struct grub_efi_pci_io *this,
> +					 grub_efi_uint64_t attributes,
> +					 grub_efi_uint8_t bar_index,
> +					 grub_efi_uint64_t *offset,
> +					 grub_efi_uint64_t *length);
> +struct grub_efi_pci_io {
> +  grub_efi_pci_io_poll_io_mem_t poll_mem;
> +  grub_efi_pci_io_poll_io_mem_t poll_io;
> +  grub_efi_pci_io_access_t mem;
> +  grub_efi_pci_io_access_t io;
> +  grub_efi_pci_io_config_access_t pci;
> +  grub_efi_pci_io_copy_mem_t copy_mem;
> +  grub_efi_pci_io_map_t map;
> +  grub_efi_pci_io_unmap_t unmap;
> +  grub_efi_pci_io_allocate_buffer_t allocate_buffer;
> +  grub_efi_pci_io_free_buffer_t free_buffer;
> +  grub_efi_pci_io_flush_t flush;
> +  grub_efi_pci_io_get_location_t get_location;
> +  grub_efi_pci_io_attributes_t attributes;
> +  grub_efi_pci_io_get_bar_attributes_t get_bar_attributes;
> +  grub_efi_pci_io_set_bar_attributes_t set_bar_attributes;
> +  grub_efi_uint64_t rom_size;
> +  void *rom_image;
> +};
> +typedef struct grub_efi_pci_io grub_efi_pci_io_t;
> +
> +struct grub_efi_pci_root_io;
> +
> +typedef struct
> +{
> +  grub_efi_status_t(*read) (struct grub_efi_pci_root_io *this,
> +			    grub_efi_pci_io_width_t width,
> +			    grub_efi_uint64_t address,
> +			    grub_efi_uintn_t count,
> +			    void *buffer);
> +  grub_efi_status_t(*write) (struct grub_efi_pci_root_io *this,
> +			     grub_efi_pci_io_width_t width,
> +			     grub_efi_uint64_t address,
> +			     grub_efi_uintn_t count,
> +			     void *buffer);
> +} grub_efi_pci_root_io_access_t;
> +
> +typedef enum
> +  {
> +    GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_READ,
> +    GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_WRITE,
> +    GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_COMMON_BUFFER,
> +    GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_READ_64,
> +    GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_WRITE_64,
> +    GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_COMMON_BUFFER_64,
> +    GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_MAXIMUM
> +  }
> +  grub_efi_pci_root_io_operation_t;
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_poll_io_mem_t) (struct grub_efi_pci_root_io *this,
> +				       grub_efi_pci_io_width_t  width,
> +				       grub_efi_uint64_t address,
> +				       grub_efi_uint64_t mask,
> +				       grub_efi_uint64_t value,
> +				       grub_efi_uint64_t delay,
> +				       grub_efi_uint64_t *result);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_copy_mem_t) (struct grub_efi_pci_root_io *this,
> +				    grub_efi_pci_io_width_t width,
> +				    grub_efi_uint64_t dest_offset,
> +				    grub_efi_uint64_t src_offset,
> +				    grub_efi_uintn_t count);
> +
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_map_t) (struct grub_efi_pci_root_io *this,
> +				grub_efi_pci_root_io_operation_t operation,
> +			       void *host_address,
> +			       grub_efi_uintn_t *number_of_bytes,
> +			       grub_efi_uint64_t *device_address,
> +			       void **mapping);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_unmap_t) (struct grub_efi_pci_root_io *this,
> +				 void *mapping);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_allocate_buffer_t) (struct grub_efi_pci_root_io *this,
> +					   grub_efi_allocate_type_t type,
> +					   grub_efi_memory_type_t memory_type,
> +					   grub_efi_uintn_t pages,
> +					   void **host_address,
> +					   grub_efi_uint64_t attributes);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_free_buffer_t) (struct grub_efi_pci_root_io *this,
> +				       grub_efi_uintn_t pages,
> +				       void **host_address);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_flush_t) (struct grub_efi_pci_root_io *this);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_get_attributes_t) (struct grub_efi_pci_root_io *this,
> +					  grub_efi_uint64_t *supports,
> +					  void **resources);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_set_attributes_t) (struct grub_efi_pci_root_io *this,
> +					  grub_efi_uint64_t attributes,
> +					  grub_efi_uint64_t *offset,
> +					  grub_efi_uint64_t *length);
> +
> +typedef grub_efi_status_t
> +(*grub_efi_pci_root_io_configuration_t) (struct grub_efi_pci_root_io *this,
> +					 void **resources);
> +
> +struct grub_efi_pci_root_io {
> +  grub_efi_handle_t parent;
> +  grub_efi_pci_root_io_poll_io_mem_t poll_mem;
> +  grub_efi_pci_root_io_poll_io_mem_t poll_io;
> +  grub_efi_pci_root_io_access_t mem;
> +  grub_efi_pci_root_io_access_t io;
> +  grub_efi_pci_root_io_access_t pci;
> +  grub_efi_pci_root_io_copy_mem_t copy_mem;
> +  grub_efi_pci_root_io_map_t map;
> +  grub_efi_pci_root_io_unmap_t unmap;
> +  grub_efi_pci_root_io_allocate_buffer_t allocate_buffer;
> +  grub_efi_pci_root_io_free_buffer_t free_buffer;
> +  grub_efi_pci_root_io_flush_t flush;
> +  grub_efi_pci_root_io_get_attributes_t get_attributes;
> +  grub_efi_pci_root_io_set_attributes_t set_attributes;
> +  grub_efi_pci_root_io_configuration_t configuration;
> +};
> +
> +typedef struct grub_efi_pci_root_io grub_efi_pci_root_io_t;
> +
> +#endif  /* !GRUB_EFI_PCI_HEADER */
> -- 1.7.7.6 _______________________________________________ Grub-devel 
> mailing list Grub-devel@gnu.org 
> https://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



  reply	other threads:[~2012-02-08 19:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-08 16:51 Some improvements to EFI GOP support Matthew Garrett
2012-02-08 16:51 ` [PATCH 1/4] Add PCI protocols Matthew Garrett
2012-02-08 19:51   ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2012-02-08 16:51 ` [PATCH 2/4] Add grub_efi_get_variable Matthew Garrett
2012-02-08 19:55   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-08 20:04     ` Matthew Garrett
2012-02-08 20:09       ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-08 20:19         ` Matthew Garrett
2012-02-08 20:29           ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-08 16:51 ` [PATCH 3/4] Prefer GOP devices which implement the pci_io protocol Matthew Garrett
2012-02-08 19:59   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-08 16:51 ` [PATCH 4/4] Add support for getting EDID via EFI Matthew Garrett
2012-02-08 20:07   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-08 17:02 ` Some improvements to EFI GOP support Keshav P R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F32D225.6000106@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=mjg@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.