aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64
diff options
context:
space:
mode:
authorManeesh Soni <maneesh@in.ibm.com>2005-06-25 17:58:28 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 19:24:55 -0400
commit72414d3f1d22fc3e311b162fca95c430048d38ce (patch)
tree46850947c1602357dd3c51d8d6ebaa5805507f9f /arch/x86_64
parent4f339ecb30c759f94a29992d4635d9194132b6cf (diff)
[PATCH] kexec code cleanup
o Following patch provides purely cosmetic changes and corrects CodingStyle guide lines related certain issues like below in kexec related files o braces for one line "if" statements, "for" loops, o more than 80 column wide lines, o No space after "while", "for" and "switch" key words o Changes: o take-2: Removed the extra tab before "case" key words. o take-3: Put operator at the end of line and space before "*/" Signed-off-by: Maneesh Soni <maneesh@in.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/kernel/machine_kexec.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/arch/x86_64/kernel/machine_kexec.c b/arch/x86_64/kernel/machine_kexec.c
index 200b5993f8d9..60d1eff41567 100644
--- a/arch/x86_64/kernel/machine_kexec.c
+++ b/arch/x86_64/kernel/machine_kexec.c
@@ -32,29 +32,31 @@
32#define L2_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 32#define L2_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
33#define L3_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 33#define L3_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
34 34
35static void init_level2_page( 35static void init_level2_page(u64 *level2p, unsigned long addr)
36 u64 *level2p, unsigned long addr)
37{ 36{
38 unsigned long end_addr; 37 unsigned long end_addr;
38
39 addr &= PAGE_MASK; 39 addr &= PAGE_MASK;
40 end_addr = addr + LEVEL2_SIZE; 40 end_addr = addr + LEVEL2_SIZE;
41 while(addr < end_addr) { 41 while (addr < end_addr) {
42 *(level2p++) = addr | L1_ATTR; 42 *(level2p++) = addr | L1_ATTR;
43 addr += LEVEL1_SIZE; 43 addr += LEVEL1_SIZE;
44 } 44 }
45} 45}
46 46
47static int init_level3_page(struct kimage *image, 47static int init_level3_page(struct kimage *image, u64 *level3p,
48 u64 *level3p, unsigned long addr, unsigned long last_addr) 48 unsigned long addr, unsigned long last_addr)
49{ 49{
50 unsigned long end_addr; 50 unsigned long end_addr;
51 int result; 51 int result;
52
52 result = 0; 53 result = 0;
53 addr &= PAGE_MASK; 54 addr &= PAGE_MASK;
54 end_addr = addr + LEVEL3_SIZE; 55 end_addr = addr + LEVEL3_SIZE;
55 while((addr < last_addr) && (addr < end_addr)) { 56 while ((addr < last_addr) && (addr < end_addr)) {
56 struct page *page; 57 struct page *page;
57 u64 *level2p; 58 u64 *level2p;
59
58 page = kimage_alloc_control_pages(image, 0); 60 page = kimage_alloc_control_pages(image, 0);
59 if (!page) { 61 if (!page) {
60 result = -ENOMEM; 62 result = -ENOMEM;
@@ -66,7 +68,7 @@ static int init_level3_page(struct kimage *image,
66 addr += LEVEL2_SIZE; 68 addr += LEVEL2_SIZE;
67 } 69 }
68 /* clear the unused entries */ 70 /* clear the unused entries */
69 while(addr < end_addr) { 71 while (addr < end_addr) {
70 *(level3p++) = 0; 72 *(level3p++) = 0;
71 addr += LEVEL2_SIZE; 73 addr += LEVEL2_SIZE;
72 } 74 }
@@ -75,17 +77,19 @@ out:
75} 77}
76 78
77 79
78static int init_level4_page(struct kimage *image, 80static int init_level4_page(struct kimage *image, u64 *level4p,
79 u64 *level4p, unsigned long addr, unsigned long last_addr) 81 unsigned long addr, unsigned long last_addr)
80{ 82{
81 unsigned long end_addr; 83 unsigned long end_addr;
82 int result; 84 int result;
85
83 result = 0; 86 result = 0;
84 addr &= PAGE_MASK; 87 addr &= PAGE_MASK;
85 end_addr = addr + LEVEL4_SIZE; 88 end_addr = addr + LEVEL4_SIZE;
86 while((addr < last_addr) && (addr < end_addr)) { 89 while ((addr < last_addr) && (addr < end_addr)) {
87 struct page *page; 90 struct page *page;
88 u64 *level3p; 91 u64 *level3p;
92
89 page = kimage_alloc_control_pages(image, 0); 93 page = kimage_alloc_control_pages(image, 0);
90 if (!page) { 94 if (!page) {
91 result = -ENOMEM; 95 result = -ENOMEM;
@@ -100,11 +104,11 @@ static int init_level4_page(struct kimage *image,
100 addr += LEVEL3_SIZE; 104 addr += LEVEL3_SIZE;
101 } 105 }
102 /* clear the unused entries */ 106 /* clear the unused entries */
103 while(addr < end_addr) { 107 while (addr < end_addr) {
104 *(level4p++) = 0; 108 *(level4p++) = 0;
105 addr += LEVEL3_SIZE; 109 addr += LEVEL3_SIZE;
106 } 110 }
107 out: 111out:
108 return result; 112 return result;
109} 113}
110 114
@@ -113,7 +117,7 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
113{ 117{
114 u64 *level4p; 118 u64 *level4p;
115 level4p = (u64 *)__va(start_pgtable); 119 level4p = (u64 *)__va(start_pgtable);
116 return init_level4_page(image, level4p, 0, end_pfn << PAGE_SHIFT); 120 return init_level4_page(image, level4p, 0, end_pfn << PAGE_SHIFT);
117} 121}
118 122
119static void set_idt(void *newidt, u16 limit) 123static void set_idt(void *newidt, u16 limit)
@@ -159,9 +163,10 @@ static void load_segments(void)
159#undef __STR 163#undef __STR
160} 164}
161 165
162typedef NORET_TYPE void (*relocate_new_kernel_t)( 166typedef NORET_TYPE void (*relocate_new_kernel_t)(unsigned long indirection_page,
163 unsigned long indirection_page, unsigned long control_code_buffer, 167 unsigned long control_code_buffer,
164 unsigned long start_address, unsigned long pgtable) ATTRIB_NORET; 168 unsigned long start_address,
169 unsigned long pgtable) ATTRIB_NORET;
165 170
166const extern unsigned char relocate_new_kernel[]; 171const extern unsigned char relocate_new_kernel[];
167const extern unsigned long relocate_new_kernel_size; 172const extern unsigned long relocate_new_kernel_size;
@@ -172,17 +177,17 @@ int machine_kexec_prepare(struct kimage *image)
172 int result; 177 int result;
173 178
174 /* Calculate the offsets */ 179 /* Calculate the offsets */
175 start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT; 180 start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
176 control_code_buffer = start_pgtable + 4096UL; 181 control_code_buffer = start_pgtable + 4096UL;
177 182
178 /* Setup the identity mapped 64bit page table */ 183 /* Setup the identity mapped 64bit page table */
179 result = init_pgtable(image, start_pgtable); 184 result = init_pgtable(image, start_pgtable);
180 if (result) { 185 if (result)
181 return result; 186 return result;
182 }
183 187
184 /* Place the code in the reboot code buffer */ 188 /* Place the code in the reboot code buffer */
185 memcpy(__va(control_code_buffer), relocate_new_kernel, relocate_new_kernel_size); 189 memcpy(__va(control_code_buffer), relocate_new_kernel,
190 relocate_new_kernel_size);
186 191
187 return 0; 192 return 0;
188} 193}
@@ -207,8 +212,8 @@ NORET_TYPE void machine_kexec(struct kimage *image)
207 local_irq_disable(); 212 local_irq_disable();
208 213
209 /* Calculate the offsets */ 214 /* Calculate the offsets */
210 page_list = image->head; 215 page_list = image->head;
211 start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT; 216 start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
212 control_code_buffer = start_pgtable + 4096UL; 217 control_code_buffer = start_pgtable + 4096UL;
213 218
214 /* Set the low half of the page table to my identity mapped 219 /* Set the low half of the page table to my identity mapped