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-changelog

[Xen-changelog] [xen-unstable] [IA64] White space cleanup from nvram pat

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [IA64] White space cleanup from nvram patch
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 16 Jun 2007 05:50:14 -0700
Delivery-date: Sat, 16 Jun 2007 05:48:40 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1181593145 21600
# Node ID 71377eab1874e126caeb4c1869374befa07f1c70
# Parent  51f5bea7b0d84d639a9823ddf1d27a71a869b6f4
[IA64] White space cleanup from nvram patch

This file is using space indenting.  No functional changes.

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
---
 tools/libxc/ia64/xc_ia64_hvm_build.c |  302 +++++++++++++++++------------------
 1 files changed, 150 insertions(+), 152 deletions(-)

diff -r 51f5bea7b0d8 -r 71377eab1874 tools/libxc/ia64/xc_ia64_hvm_build.c
--- a/tools/libxc/ia64/xc_ia64_hvm_build.c      Mon Jun 11 13:59:48 2007 -0600
+++ b/tools/libxc/ia64/xc_ia64_hvm_build.c      Mon Jun 11 14:19:05 2007 -0600
@@ -124,7 +124,7 @@ typedef enum {
     HOB_TYPE_PAL_VM_INFO,
     HOB_TYPE_PAL_VM_PAGE_SIZE,
     HOB_TYPE_NR_VCPU,
-       HOB_TYPE_NVRAM,
+    HOB_TYPE_NVRAM,
     HOB_TYPE_MAX
 } hob_type_t;
 
@@ -135,14 +135,14 @@ static int add_nvram_hob(void* hob_buf, 
 static int add_nvram_hob(void* hob_buf, unsigned long nvram_addr);
 static int build_hob(void* hob_buf, unsigned long hob_buf_size,
                      unsigned long dom_mem_size, unsigned long vcpus,
-                                        unsigned long nvram_addr);
+                     unsigned long nvram_addr);
 static int load_hob(int xc_handle,uint32_t dom, void *hob_buf,
                     unsigned long dom_mem_size);
 
 static int
 xc_ia64_build_hob(int xc_handle, uint32_t dom,
                   unsigned long memsize, unsigned long vcpus,
-                                 unsigned long nvram_addr)
+                  unsigned long nvram_addr)
 {
     char   *hob_buf;
 
@@ -251,7 +251,7 @@ static int
 static int
 build_hob(void* hob_buf, unsigned long hob_buf_size,
           unsigned long dom_mem_size, unsigned long vcpus,
-                 unsigned long nvram_addr)
+          unsigned long nvram_addr)
 {
     //Init HOB List
     if (hob_init(hob_buf, hob_buf_size) < 0) {
@@ -274,10 +274,10 @@ build_hob(void* hob_buf, unsigned long h
         goto err_out;
     }
 
-       if (add_nvram_hob( hob_buf, nvram_addr ) < 0) {
-               PERROR("Add nvram hob failed, buffer too small");
-               goto err_out;
-       }
+    if (add_nvram_hob( hob_buf, nvram_addr ) < 0) {
+        PERROR("Add nvram hob failed, buffer too small");
+        goto err_out;
+    }
 
     return 0;
 
@@ -342,7 +342,7 @@ static int
 static int
 add_nvram_hob(void *hob_buf, unsigned long nvram_addr)
 {
-       return hob_add(hob_buf, HOB_TYPE_NVRAM, &nvram_addr, 
sizeof(nvram_addr));
+    return hob_add(hob_buf, HOB_TYPE_NVRAM, &nvram_addr, sizeof(nvram_addr));
 }
 
 static const unsigned char config_pal_bus_get_features_data[24] = {
@@ -576,49 +576,48 @@ static uint64_t
 static uint64_t 
 nvram_init(const char *nvram_path)
 {
-       uint64_t fd = 0;
-       fd = open(nvram_path, O_CREAT|O_RDWR, 0666);
-
-       if ( fd < 0 )
-       {
-               PERROR("Nvram open failed at %s. Guest will boot without"
-                               " nvram support!\n", nvram_path);       
-               return -1;
-       }
-
-       return VALIDATE_NVRAM_FD(fd);
+    uint64_t fd = 0;
+    fd = open(nvram_path, O_CREAT|O_RDWR, 0666);
+
+    if ( fd < 0 )
+    {
+        PERROR("Nvram open failed at %s. Guest will boot without"
+               " nvram support!\n", nvram_path);       
+        return -1;
+    }
+
+    return VALIDATE_NVRAM_FD(fd);
 }
 
 static int 
 copy_from_nvram_to_GFW(int xc_handle, uint32_t dom, int nvram_fd)
 {
-       unsigned int nr_pages = NVRAM_SIZE >> PAGE_SHIFT;
-       struct stat file_stat;
-       char buf[NVRAM_SIZE] = {0};
+    unsigned int nr_pages = NVRAM_SIZE >> PAGE_SHIFT;
+    struct stat file_stat;
+    char buf[NVRAM_SIZE] = {0};
        
-       if ( fstat(nvram_fd, &file_stat) < 0 )
-       {
-               PERROR("Cannot get Nvram file info! Guest will boot without "
-                          "nvram support!\n");
-               return -1;
-       }
-
-       if ( 0 == file_stat.st_size )
-       {
-               DPRINTF("Nvram file create successful!\n");
-               return 0;
-       }
-
-       if ( read(nvram_fd, buf, NVRAM_SIZE) != NVRAM_SIZE )
-       {
-               PERROR("Load nvram fail. guest will boot without"
-                          " nvram support!\n");
-               return -1;
-       }
-
-       return  xc_ia64_copy_to_domain_pages(xc_handle, dom, buf,
-                                                                               
        NVRAM_START >> PAGE_SHIFT,
-                                                                               
        nr_pages);
+    if ( fstat(nvram_fd, &file_stat) < 0 )
+    {
+        PERROR("Cannot get Nvram file info! Guest will boot without "
+               "nvram support!\n");
+        return -1;
+    }
+
+    if ( 0 == file_stat.st_size )
+    {
+        DPRINTF("Nvram file create successful!\n");
+        return 0;
+    }
+
+    if ( read(nvram_fd, buf, NVRAM_SIZE) != NVRAM_SIZE )
+    {
+        PERROR("Load nvram fail. guest will boot without"
+               " nvram support!\n");
+        return -1;
+    }
+
+    return  xc_ia64_copy_to_domain_pages(xc_handle, dom, buf,
+                                         NVRAM_START >> PAGE_SHIFT, nr_pages);
 }
 
 
@@ -630,121 +629,120 @@ static int
 static int
 copy_from_GFW_to_nvram(int xc_handle, uint32_t dom, int nvram_fd)
 {
-       xen_pfn_t *pfn_list = NULL;
-       char *tmp_ptr = NULL;
-       unsigned int nr_pages = 0;
-       uint64_t addr_from_GFW_4k_align = 0;
-       uint32_t offset = 0;
-       uint64_t nvram_base_addr = 0;
-       char buf[NVRAM_SIZE] = {0};
-       int i;
-
-       
-       // map one more page 
-       nr_pages = (NVRAM_SIZE + PAGE_SIZE) >> PAGE_SHIFT;
-       pfn_list = (xen_pfn_t *)malloc(sizeof(xen_pfn_t) * nr_pages);
-       if ( NULL == pfn_list )
-       {
-               PERROR("Cannot allocate memory for nvram save!\n");
-               close(nvram_fd);
-               return -1;
-       }
-
-       /* 
-        * GFW allocate memory dynamicly to save nvram data
-        * and save address of the dynamic memory at NVRAM_START. 
-        * To save nvram data to file, we must get the dynamic
-        * memory address first.
-        */
-       pfn_list[0] = NVRAM_START >> PAGE_SHIFT;
-       tmp_ptr = (char *)xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
-                       PROT_READ | PROT_WRITE, pfn_list[0]);
-
-       if ( NULL == tmp_ptr )
-       {
-               PERROR("Cannot get nvram data from GFW!\n");
-               free(pfn_list);
-               close(nvram_fd);
-               return -1;
-       }
-
-       addr_from_GFW_4k_align = *((uint64_t *)tmp_ptr);
-       munmap(tmp_ptr, PAGE_SIZE);
-
-       // align address to 16k
-       offset = addr_from_GFW_4k_align % ( 16 * MEM_K );
-       addr_from_GFW_4k_align = addr_from_GFW_4k_align - offset;
-       for ( i=0; i<nr_pages; i++ )
-               pfn_list[i] = (addr_from_GFW_4k_align >> PAGE_SHIFT) + i;
-
-       tmp_ptr = (char *)xc_map_foreign_batch(xc_handle, dom,
-                                               PROT_READ | PROT_WRITE, 
pfn_list, nr_pages);
-       if ( NULL == tmp_ptr )
-       {
-               PERROR("Cannot get nvram data from GFW!\n");
-               free(pfn_list);
-               close(nvram_fd);
-               return -1;
-       }
-
-       // calculate nvram data base addrees
-       nvram_base_addr = (uint64_t)(tmp_ptr + offset);
-
-       memcpy(buf, (void *)nvram_base_addr, NVRAM_SIZE);
-       free(pfn_list);
-       munmap(tmp_ptr, NVRAM_SIZE + PAGE_SIZE);
-
-       lseek(nvram_fd, 0, SEEK_SET);
-       if ( write(nvram_fd, buf, NVRAM_SIZE) != NVRAM_SIZE )
-       {
-               PERROR("Save to nvram fail!\n");
-               return -1;
-       }
-
-       close(nvram_fd);
-
-       DPRINTF("Nvram save successful!\n");
-
-       return 0;
+    xen_pfn_t *pfn_list = NULL;
+    char *tmp_ptr = NULL;
+    unsigned int nr_pages = 0;
+    uint64_t addr_from_GFW_4k_align = 0;
+    uint32_t offset = 0;
+    uint64_t nvram_base_addr = 0;
+    char buf[NVRAM_SIZE] = {0};
+    int i;
+
+    // map one more page 
+    nr_pages = (NVRAM_SIZE + PAGE_SIZE) >> PAGE_SHIFT;
+    pfn_list = (xen_pfn_t *)malloc(sizeof(xen_pfn_t) * nr_pages);
+    if ( NULL == pfn_list )
+    {
+        PERROR("Cannot allocate memory for nvram save!\n");
+        close(nvram_fd);
+        return -1;
+    }
+
+    /* 
+     * GFW allocate memory dynamicly to save nvram data
+     * and save address of the dynamic memory at NVRAM_START. 
+     * To save nvram data to file, we must get the dynamic
+     * memory address first.
+     */
+    pfn_list[0] = NVRAM_START >> PAGE_SHIFT;
+    tmp_ptr = (char *)xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
+                                           PROT_READ | PROT_WRITE, 
pfn_list[0]);
+
+    if ( NULL == tmp_ptr )
+    {
+        PERROR("Cannot get nvram data from GFW!\n");
+        free(pfn_list);
+        close(nvram_fd);
+        return -1;
+    }
+
+    addr_from_GFW_4k_align = *((uint64_t *)tmp_ptr);
+    munmap(tmp_ptr, PAGE_SIZE);
+
+    // align address to 16k
+    offset = addr_from_GFW_4k_align % ( 16 * MEM_K );
+    addr_from_GFW_4k_align = addr_from_GFW_4k_align - offset;
+    for ( i=0; i<nr_pages; i++ )
+        pfn_list[i] = (addr_from_GFW_4k_align >> PAGE_SHIFT) + i;
+
+    tmp_ptr = (char *)xc_map_foreign_batch(xc_handle, dom,
+    PROT_READ | PROT_WRITE, pfn_list, nr_pages);
+    if ( NULL == tmp_ptr )
+    {
+        PERROR("Cannot get nvram data from GFW!\n");
+        free(pfn_list);
+        close(nvram_fd);
+        return -1;
+    }
+
+    // calculate nvram data base addrees
+    nvram_base_addr = (uint64_t)(tmp_ptr + offset);
+
+    memcpy(buf, (void *)nvram_base_addr, NVRAM_SIZE);
+    free(pfn_list);
+    munmap(tmp_ptr, NVRAM_SIZE + PAGE_SIZE);
+
+    lseek(nvram_fd, 0, SEEK_SET);
+    if ( write(nvram_fd, buf, NVRAM_SIZE) != NVRAM_SIZE )
+    {
+        PERROR("Save to nvram fail!\n");
+        return -1;
+    }
+
+    close(nvram_fd);
+
+    DPRINTF("Nvram save successful!\n");
+
+    return 0;
 }
 
 int xc_ia64_save_to_nvram(int xc_handle, uint32_t dom) 
 {
-       uint64_t nvram_fd = 0;
-       xc_get_hvm_param(xc_handle, dom, HVM_PARAM_NVRAM_FD, &nvram_fd);
-
-       if ( !IS_VALID_NVRAM_FD(nvram_fd) )
-       {
-               PERROR("Nvram not be initialized. Nvram save fail!\n");
-               return -1;
-       }
-       return copy_from_GFW_to_nvram(xc_handle, dom, (int)nvram_fd);   
+    uint64_t nvram_fd = 0;
+    xc_get_hvm_param(xc_handle, dom, HVM_PARAM_NVRAM_FD, &nvram_fd);
+
+    if ( !IS_VALID_NVRAM_FD(nvram_fd) )
+    {
+        PERROR("Nvram not be initialized. Nvram save fail!\n");
+        return -1;
+    }
+    return copy_from_GFW_to_nvram(xc_handle, dom, (int)nvram_fd);      
 }
 
 #define NVRAM_FILE_PATH        "/usr/lib/xen/boot/nvram_"
 int xc_ia64_nvram_init(int xc_handle, char *dom_name, uint32_t dom)
 {
-       int file_path_len = strlen(NVRAM_FILE_PATH);
-       uint64_t nvram_fd = 0;
-       char nvram_path[100] = {0};
-
-       strncpy(nvram_path, NVRAM_FILE_PATH, file_path_len);
-       if ( file_path_len + strlen(dom_name) + 1 > sizeof(nvram_path) )
-       {
-               PERROR("Nvram file path is too long!\n");
-               return -1;
-       }
-       strcpy(nvram_path + file_path_len, dom_name);
-
-       nvram_fd = nvram_init(nvram_path);
-       if ( nvram_fd == (uint64_t)(-1) )
-       {
-               xc_set_hvm_param(xc_handle, dom, HVM_PARAM_NVRAM_FD, 0);
-               return -1;
-       }
-
-       xc_set_hvm_param(xc_handle, dom, HVM_PARAM_NVRAM_FD, nvram_fd);
-       return 0; 
+    int file_path_len = strlen(NVRAM_FILE_PATH);
+    uint64_t nvram_fd = 0;
+    char nvram_path[100] = {0};
+
+    strncpy(nvram_path, NVRAM_FILE_PATH, file_path_len);
+    if ( file_path_len + strlen(dom_name) + 1 > sizeof(nvram_path) )
+    {
+        PERROR("Nvram file path is too long!\n");
+        return -1;
+    }
+    strcpy(nvram_path + file_path_len, dom_name);
+
+    nvram_fd = nvram_init(nvram_path);
+    if ( nvram_fd == (uint64_t)(-1) )
+    {
+        xc_set_hvm_param(xc_handle, dom, HVM_PARAM_NVRAM_FD, 0);
+        return -1;
+    }
+
+    xc_set_hvm_param(xc_handle, dom, HVM_PARAM_NVRAM_FD, nvram_fd);
+    return 0; 
 }
 
 #define GFW_PAGES (GFW_SIZE >> PAGE_SHIFT)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [IA64] White space cleanup from nvram patch, Xen patchbot-unstable <=