Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754082AbZCFRqv (ORCPT ); Fri, 6 Mar 2009 12:46:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753250AbZCFRqm (ORCPT ); Fri, 6 Mar 2009 12:46:42 -0500 Received: from relay3.sgi.com ([192.48.171.31]:35014 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753104AbZCFRql (ORCPT ); Fri, 6 Mar 2009 12:46:41 -0500 To: linux-kernel@vger.kernel.org Subject: [PATCH] x86: access to efi reserved memory type Cc: mingo@elte.hu Message-Id: From: Cliff Wickman Date: Fri, 06 Mar 2009 11:46:42 -0600 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2450 Lines: 79 From: Cliff Wickman (this patch dates back to 2008-11-06 http://marc.info/?l=linux-kernel&m=122600658522471&w=2 but has never been applied.) Give drivers addresses of memory type EFI_RESERVED_TYPE. This supports drivers that use vendor-specific memory, available only to special devices. The walk() function scans the EFI memory map and does a callback to a specified function for each memory area of a specified type. efi_memmap_walk_reserved() provides a scan for type EFI_RESERVED_TYPE. (an earlier version of this patch had proposed a new EFI type, but EFI_RESERVED_TYPE should be sufficient, given that the firmware follows the standard and does not use such memory for its own purposes) A UV driver will be posted to the community in the future that will use these routines. Tested on 2.6.29-rc7 (and many previous versions) running on a UV hardware simulator. Diffed against 2.6.29-rc7 Signed-off-by: Cliff Wickman --- arch/x86/kernel/efi.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) Index: linux/arch/x86/kernel/efi.c =================================================================== --- linux.orig/arch/x86/kernel/efi.c +++ linux/arch/x86/kernel/efi.c @@ -579,3 +579,39 @@ u64 efi_mem_attributes(unsigned long phy } return 0; } + +static void +walk(efi_freemem_callback_t callback, void *arg, int type) +{ + efi_memory_desc_t *md; + void *p; + int size; + + /* + * memmap.map is zeroed in efi_enter_virtual_mode() + * but we can use the physical address (phys_map) + */ + size = memmap.nr_map*memmap.desc_size; + for (p = memmap.phys_map; p < memmap.phys_map+size; + p += memmap.desc_size) { + md = (efi_memory_desc_t *)__va(p); + if (md->type != type) + continue; + if ((*callback)(md->phys_addr, + md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1, + arg) < 0) + return; + } +} + +/* + * Walk the EFI memory map and call "callback" once for each EFI memory + * descriptor of type EFI_RESERVED_TYPE. + */ +void +efi_memmap_walk_reserved(efi_freemem_callback_t callback, void *arg) +{ + walk(callback, arg, EFI_RESERVED_TYPE); +} + +EXPORT_SYMBOL(efi_memmap_walk_reserved); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/