WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [rfc 2/3] Allow architectures to specify the location o

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [rfc 2/3] Allow architectures to specify the location of /proc/iomem
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Fri, 17 Aug 2007 16:36:07 +0900
Delivery-date: Fri, 17 Aug 2007 01:09:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20070817073605.208529182@xxxxxxxxxxxx>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
On some ia64 XEN it is neccessary to use an alternate location
for the iformation that is usually provided by /proc/iomem.
By having the path returned by a function, which can be
overriden on a per-architecture basis, it is possible for
ia64 XEN to make use of existing generic code. Hopefully other
achitectures can use this infastructure as the need arises.

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

Index: kexec-tools-unstable/kexec/arch/i386/crashdump-x86.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/i386/crashdump-x86.c   2007-05-09 
16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/i386/crashdump-x86.c        2007-05-09 
16:55:42.000000000 +0900
@@ -59,7 +59,7 @@ static struct memory_range crash_reserve
  */
 static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
 {
-       const char iomem[]= "/proc/iomem";
+       const char *iomem = proc_iomem();
        int memory_ranges = 0;
        char line[MAX_LINE];
        FILE *fp;
Index: kexec-tools-unstable/kexec/arch/i386/kexec-x86.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/i386/kexec-x86.c       2007-05-09 
16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/i386/kexec-x86.c    2007-05-09 
16:55:42.000000000 +0900
@@ -39,7 +39,7 @@ static struct memory_range memory_range[
 int get_memory_ranges(struct memory_range **range, int *ranges,
                                unsigned long kexec_flags)
 {
-       const char iomem[]= "/proc/iomem";
+       const char *iomem= proc_iomem();
        int memory_ranges = 0;
        char line[MAX_LINE];
        FILE *fp;
Index: kexec-tools-unstable/kexec/arch/i386/x86-linux-setup.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/i386/x86-linux-setup.c 2007-05-09 
16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/i386/x86-linux-setup.c      2007-05-09 
16:55:42.000000000 +0900
@@ -126,7 +126,7 @@ int setup_linux_vesafb(struct x86_linux_
        real_mode->lfb_linelength = fix.line_length;
        real_mode->vesapm_seg     = 0;
 
-       /* FIXME: better get size from /proc/iomem */
+       /* FIXME: better get size from the file returned by proc_iomem() */
        real_mode->lfb_size       = (fix.smem_len + 65535) / 65536;
        real_mode->pages          = (fix.smem_len + 4095) / 4096;
 
Index: kexec-tools-unstable/kexec/arch/ia64/crashdump-ia64.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/ia64/crashdump-ia64.c  2007-05-09 
16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/ia64/crashdump-ia64.c       2007-05-09 
17:03:15.000000000 +0900
@@ -43,7 +43,8 @@ static struct crash_elf_info elf_info =
 /* Stores a sorted list of RAM memory ranges for which to create elf headers.
  * A separate program header is created for backup region.
  * The number of entries in memory_range array is always smaller than
- * the number of entries in /proc/iomem, stored in max_memory_ranges. */
+ * the number of entries in the file returned by proc_iomem(),
+ * stored in max_memory_ranges. */
 static struct memory_range *crash_memory_range;
 /* Memory region reserved for storing panic kernel and other data. */
 static struct memory_range crash_reserved_mem;
@@ -142,7 +143,7 @@ static int exclude_crash_reserve_region(
 
 static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
 {
-       const char iomem[]= "/proc/iomem";
+       const char *iomem = proc_iomem();
         char line[MAX_LINE];
         FILE *fp;
         unsigned long start, end;
Index: kexec-tools-unstable/kexec/arch/ia64/kexec-elf-ia64.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/ia64/kexec-elf-ia64.c  2007-05-09 
16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/ia64/kexec-elf-ia64.c       2007-05-09 
16:55:42.000000000 +0900
@@ -195,7 +195,7 @@ int elf_ia64_load(int argc, char **argv,
        if (info->kexec_flags & KEXEC_ON_CRASH ) {
                if ((mem_min == 0x00) && (mem_max == ULONG_MAX)) {
                        fprintf(stderr, "Failed to find crash kernel region "
-                               "in /proc/iomem\n");
+                               "in %s\n", proc_iomem());
                        free_elf_info(&ehdr);
                        return -1;
                }
Index: kexec-tools-unstable/kexec/arch/ia64/kexec-ia64.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/ia64/kexec-ia64.c      2007-05-09 
16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/ia64/kexec-ia64.c   2007-05-09 
16:55:42.000000000 +0900
@@ -37,7 +37,8 @@
 #include <arch/options.h>
 
 /* The number of entries in memory_range array is always smaller than
-   the number of entries in /proc/iomem, stored in max_memory_ranges. */
+ * the number of entries in the file returned by proc_iomem(),
+ * stored in max_memory_ranges. */
 static struct memory_range *memory_range;
 int max_memory_ranges;
 static int memory_ranges;
@@ -79,7 +80,7 @@ static int split_range(int range, unsign
 int get_memory_ranges(struct memory_range **range, int *ranges,
                                unsigned long kexec_flags)
 {
-       const char iomem[]= "/proc/iomem";
+       const char *iomem = proc_iomem();
        char line[MAX_LINE];
        FILE *fp;
        fp = fopen(iomem, "r");
Index: kexec-tools-unstable/kexec/arch/ppc/kexec-ppc.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/ppc/kexec-ppc.c        2007-05-09 
16:55:32.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/ppc/kexec-ppc.c     2007-05-09 
16:55:42.000000000 +0900
@@ -34,7 +34,7 @@ int get_memory_ranges(struct memory_rang
        memory_ranges++;
 #else
 #error Please, fix this for your platform
-       const char iomem[] = "/proc/iomem";
+       const char *iomem = proc_iomem();
        char line[MAX_LINE];
        FILE *fp;
        unsigned long long start, end;
Index: kexec-tools-unstable/kexec/arch/s390/kexec-s390.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/s390/kexec-s390.c      2007-05-09 
16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/s390/kexec-s390.c   2007-05-09 
16:55:42.000000000 +0900
@@ -25,7 +25,8 @@ static struct memory_range memory_range[
 
 /*
  * get_memory_ranges:
- *  Return a list of memory ranges by parsing /proc/iomem
+ *  Return a list of memory ranges by parsing the file returned by
+ *  proc_iomem()
  *
  * INPUT:
  *  - Pointer to an array of memory_range structures.
@@ -39,7 +40,7 @@ static struct memory_range memory_range[
 int get_memory_ranges(struct memory_range **range, int *ranges, unsigned long 
flags)
 {
        char sys_ram[] = "System RAM\n";
-       char iomem[] = "/proc/iomem";
+       char *iomem = proc_iomem();
        FILE *fp;
        char line[80];
        int current_range = 0;
Index: kexec-tools-unstable/kexec/arch/x86_64/crashdump-x86_64.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/x86_64/crashdump-x86_64.c      
2007-05-09 16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/x86_64/crashdump-x86_64.c   2007-05-09 
16:55:42.000000000 +0900
@@ -52,8 +52,8 @@ static int exclude_crash_reserve_region(
 
 #define KERN_VADDR_ALIGN       0x100000        /* 1MB */
 
-/* Read kernel physical load addr from /proc/iomem (Kernel Code) and
- * store in kexec_info */
+/* Read kernel physical load addr from the file returned by proc_iomem()
+ * (Kernel Code) and store in kexec_info */
 static int get_kernel_paddr(struct kexec_info *info)
 {
        uint64_t start;
@@ -164,7 +164,7 @@ static struct memory_range crash_reserve
  */
 static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
 {
-       const char iomem[]= "/proc/iomem";
+       const char *iomem= proc_iomem();
        int memory_ranges = 0;
        char line[MAX_LINE];
        FILE *fp;
Index: kexec-tools-unstable/kexec/arch/x86_64/kexec-x86_64.c
===================================================================
--- kexec-tools-unstable.orig/kexec/arch/x86_64/kexec-x86_64.c  2007-05-09 
16:55:33.000000000 +0900
+++ kexec-tools-unstable/kexec/arch/x86_64/kexec-x86_64.c       2007-05-09 
16:55:42.000000000 +0900
@@ -40,7 +40,7 @@ static struct memory_range memory_range[
 int get_memory_ranges(struct memory_range **range, int *ranges,
                                        unsigned long kexec_flags)
 {
-       const char iomem[]= "/proc/iomem";
+       const char *iomem= proc_iomem();
        int memory_ranges = 0;
        char line[MAX_LINE];
        FILE *fp;
Index: kexec-tools-unstable/kexec/kexec-iomem.c
===================================================================
--- kexec-tools-unstable.orig/kexec/kexec-iomem.c       2007-05-09 
16:55:32.000000000 +0900
+++ kexec-tools-unstable/kexec/kexec-iomem.c    2007-05-09 17:02:19.000000000 
+0900
@@ -15,8 +15,10 @@
 /*
  * kexec_iomem_for_each_line()
  *
- * Iterate over each line in /proc/iomem. If match is NULL or if the line
- * matches with our match-pattern then call the callback if non-NULL.
+ * Iterate over each line in the file returned by proc_iomem(). If match is
+ * NULL or if the line matches with our match-pattern then call the
+ * callback if non-NULL.
+ *
  * Return the number of lines matched.
  */
 
@@ -28,7 +30,7 @@ int kexec_iomem_for_each_line(char *matc
                                              unsigned long length),
                              void *data)
 {
-       const char iomem[]= "/proc/iomem";
+       const char *iomem = proc_iomem();
        char line[MAX_LINE];
        FILE *fp;
        unsigned long long start, end, size;
@@ -39,7 +41,7 @@ int kexec_iomem_for_each_line(char *matc
 
        fp = fopen(iomem, "r");
        if (!fp)
-               die("Cannot open /proc/iomem");
+               die("Cannot open %s\n", iomem);
 
        while(fgets(line, sizeof(line), fp) != 0) {
                count = sscanf(line, "%Lx-%Lx : %n", &start, &end, &consumed);
@@ -99,3 +101,16 @@ int parse_iomem_single(char *str, uint64
 
        return ret;
 }
+
+static const char proc_iomem_str[]= "/proc/iomem";
+
+/*
+ * Allow an architecture specific implementation of this
+ * function to override the location of a file looking a lot
+ * like /proc/iomem
+ */
+const char * __attribute__((weak)) proc_iomem(void)
+{
+        return proc_iomem_str;
+}
+
Index: kexec-tools-unstable/kexec/kexec.h
===================================================================
--- kexec-tools-unstable.orig/kexec/kexec.h     2007-05-09 16:55:32.000000000 
+0900
+++ kexec-tools-unstable/kexec/kexec.h  2007-05-09 17:02:16.000000000 +0900
@@ -213,7 +213,7 @@ int kexec_iomem_for_each_line(char *matc
                                              unsigned long length),
                              void *data);
 int parse_iomem_single(char *str, uint64_t *start, uint64_t *end);
-
+const char * proc_iomem(void);
 
 #define MAX_LINE       160
 

-- 

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel

<Prev in Thread] Current Thread [Next in Thread>