Skip to content

Commit c1bcc25

Browse files
authored
Merge pull request #177 from smartobjectoriented/174-clang-formatting-issue
style: fix formatting
2 parents 6b11dca + 09b02e4 commit c1bcc25

File tree

17 files changed

+232
-299
lines changed

17 files changed

+232
-299
lines changed

so3/arch/arm32/mmu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ static void alloc_init_pte(uint32_t *l1pte, addr_t addr, addr_t end, addr_t pfn,
101101

102102
memset(l2pte, 0, size);
103103

104-
*l1pte = __pa((uint32_t)l2pte);
104+
*l1pte = __pa((uint32_t) l2pte);
105105

106106
set_l1_pte_page_dcache(l1pte, (nocache ? L1_PAGE_DCACHE_OFF : L1_PAGE_DCACHE_WRITEALLOC));
107107

108108
LOG_DEBUG("Allocating a L2 page table at %p in l1pte: %p with contents: %x\n", l2pte, l1pte, *l1pte);
109109
}
110110

111-
l2pgtable = (uint32_t *)__va(*l1pte & TTB_L1_PAGE_ADDR_MASK);
111+
l2pgtable = (uint32_t *) __va(*l1pte & TTB_L1_PAGE_ADDR_MASK);
112112

113113
l2pte = l2pte_offset(l1pte, addr);
114114

@@ -142,7 +142,7 @@ static void alloc_init_section(uint32_t *l1pte, addr_t addr, addr_t end, addr_t
142142
*l1pte = phys;
143143

144144
set_l1_pte_sect_dcache(l1pte, (nocache ? L1_SECT_DCACHE_OFF : L1_SECT_DCACHE_WRITEALLOC));
145-
145+
146146
LOG_DEBUG("Allocating a section at l1pte: %p content: %x\n", l1pte, *l1pte);
147147

148148
phys += TTB_SECT_SIZE;

so3/arch/arm64/mmu.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ static void alloc_init_l3(u64 *l0pgtable, addr_t addr, addr_t end, addr_t phys,
9494
set_pte_table(l2pte, (nocache ? DCACHE_OFF : DCACHE_WRITEALLOC));
9595
#endif
9696

97-
LOG_DEBUG("Allocating a L3 page table at %p in l2pte: %p with contents: %lx\n",
98-
l3pgtable, l2pte, *l2pte);
97+
LOG_DEBUG("Allocating a L3 page table at %p in l2pte: %p with contents: %lx\n", l3pgtable, l2pte,
98+
*l2pte);
9999
}
100100

101101
l3pte = l3pte_offset(l2pte, addr);
@@ -115,8 +115,7 @@ static void alloc_init_l3(u64 *l0pgtable, addr_t addr, addr_t end, addr_t phys,
115115
*l3pte |= PTE_BLOCK_AP1;
116116
#endif
117117

118-
LOG_DEBUG("Allocating a 4 KB page at l2pte: %p content: %lx\n", l3pte,
119-
*l3pte);
118+
LOG_DEBUG("Allocating a 4 KB page at l2pte: %p content: %lx\n", l3pte, *l3pte);
120119

121120
flush_pte_entry(addr, l3pte);
122121

@@ -167,8 +166,8 @@ static void alloc_init_l2(u64 *l0pgtable, addr_t addr, addr_t end, addr_t phys,
167166
#else
168167
set_pte_table(l1pte, (nocache ? DCACHE_OFF : DCACHE_WRITEALLOC));
169168
#endif
170-
LOG_DEBUG("Allocating a L2 page table at %p in l1pte: %p with contents: %lx\n",
171-
l2pgtable, l1pte, *l1pte);
169+
LOG_DEBUG("Allocating a L2 page table at %p in l1pte: %p with contents: %lx\n", l2pgtable, l1pte,
170+
*l1pte);
172171
}
173172

174173
l2pte = l2pte_offset(l1pte, addr);
@@ -245,8 +244,8 @@ static void alloc_init_l1(u64 *l0pgtable, addr_t addr, addr_t end, addr_t phys,
245244
#else
246245
set_pte_table(l0pte, (nocache ? DCACHE_OFF : DCACHE_WRITEALLOC));
247246
#endif
248-
LOG_DEBUG("Allocating a L1 page table at %p in l0pte: %p with contents: %lx\n",
249-
l1pgtable, l0pte, *l0pte);
247+
LOG_DEBUG("Allocating a L1 page table at %p in l0pte: %p with contents: %lx\n", l1pgtable, l0pte,
248+
*l0pte);
250249
}
251250

252251
l1pte = l1pte_offset(l0pte, addr);
@@ -271,8 +270,7 @@ static void alloc_init_l1(u64 *l0pgtable, addr_t addr, addr_t end, addr_t phys,
271270
*l1pte |= PTE_BLOCK_AP1;
272271
#endif
273272

274-
LOG_DEBUG("Allocating a 1 GB block at l1pte: %p content: %lx\n",
275-
l1pte, *l1pte);
273+
LOG_DEBUG("Allocating a 1 GB block at l1pte: %p content: %lx\n", l1pte, *l1pte);
276274

277275
flush_pte_entry(addr, l1pte);
278276

@@ -311,8 +309,7 @@ void __create_mapping(void *pgtable, addr_t virt_base, addr_t phys_base, size_t
311309

312310
BUG_ON(!size);
313311

314-
LOG_DEBUG("Create mapping for virt %llx - phys: %llx - size: %x\n", virt_base,
315-
phys_base, size);
312+
LOG_DEBUG("Create mapping for virt %llx - phys: %llx - size: %x\n", virt_base, phys_base, size);
316313
addr = virt_base & PAGE_MASK;
317314
length = ALIGN_UP(size + (virt_base & ~PAGE_MASK), PAGE_SIZE);
318315

@@ -373,8 +370,7 @@ static void __create_mapping(void *l1pgtable, addr_t virt_base, addr_t phys_base
373370
if ((addr != phys) && user_space_vaddr(addr))
374371
*l1pte |= PTE_BLOCK_AP1;
375372

376-
LOG_DEBUG("Allocating a 1 GB block at l1pte: %p content: %lx\n",
377-
l1pte, *l1pte);
373+
LOG_DEBUG("Allocating a 1 GB block at l1pte: %p content: %lx\n", l1pte, *l1pte);
378374

379375
flush_pte_entry(addr, l1pte);
380376

so3/avz/kernel/injector.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1616
*
1717
*/
18+
#define CONFIG_LOG_LEVEL LOG_LEVEL_DEBUG
1819

20+
#include <common.h>
1921
#include <heap.h>
2022
#include <memory.h>
2123
#include <crc.h>
@@ -149,7 +151,8 @@ static void build_domain_context(unsigned int ME_slotID, struct domain *me, stru
149151
if (me->avz_shared->dom_desc.u.ME.state == ME_state_suspended)
150152
domctxt->avz_shared.dom_desc.u.ME.state = ME_state_hibernate;
151153

152-
BUG_ON(me->avz_shared->dom_desc.u.ME.state != ME_state_stopped);
154+
BUG_ON((me->avz_shared->dom_desc.u.ME.state != ME_state_stopped) &&
155+
(me->avz_shared->dom_desc.u.ME.state != ME_state_suspended));
153156

154157
domctxt->pause_count = me->pause_count;
155158

@@ -198,13 +201,16 @@ void read_ME_snapshot(avz_hyp_t *args)
198201
return;
199202
}
200203

204+
/* If the capsule is living, it will be put in ME_state_suspended state by Linux
205+
* before being entering this function.
206+
*/
201207
if (domME->avz_shared->dom_desc.u.ME.state == ME_state_suspended) {
202208
/* Pause the capsule */
203209
domain_pause_by_systemcontroller(domME);
204210
}
205211

206212
/* Gather all the info we need into structures */
207-
/* This will put the capsule in state HIBERNATE */
213+
/* This will put the capsule snapshot in HIBERNATE state */
208214
build_domain_context(slotID, domME, &domain_context);
209215

210216
/* Copy the size of the payload which is made of the dom_info structure and the capsule */
@@ -313,7 +319,6 @@ void write_ME_snapshot(avz_hyp_t *args)
313319
args->u.avz_snapshot_args.slotID = slotID;
314320
else
315321
return;
316-
}
317322

318323
LOG_DEBUG("Available slotID: %d\n", args->u.avz_snapshot_args.slotID);
319324

@@ -323,8 +328,10 @@ void write_ME_snapshot(avz_hyp_t *args)
323328
domME = domains[slotID];
324329
domctxt = (struct dom_context *) (snapshot_buffer + sizeof(uint32_t));
325330

331+
LOG_DEBUG("Restoring the domain context...\n");
326332
restore_domain_context(slotID, domME, domctxt);
327333

334+
LOG_DEBUG("Set up the page tables...\n");
328335
__setup_dom_pgtable(domME, memslot[slotID].base_paddr, memslot[slotID].size);
329336

330337
/* Copy the ME content */
@@ -347,6 +354,7 @@ void write_ME_snapshot(avz_hyp_t *args)
347354

348355
/* We need to re-map the vbstore page corresponding to this slotID */
349356
map_vbstore_pfn(domME->avz_shared->domID, domME->avz_shared->dom_desc.u.ME.vbstore_pfn);
357+
LOG_DEBUG("State of the saved capsule: %d\n", domME->avz_shared->dom_desc.u.ME.state);
350358

351359
if (domME->avz_shared->dom_desc.u.ME.state != ME_state_stopped) {
352360
BUG_ON(domME->avz_shared->dom_desc.u.ME.state != ME_state_hibernate);

so3/devices/device.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ void parse_dtb(void *fdt_addr)
138138
while ((new_off = get_dev_info(fdt_addr, offset, "*", dev)) != -1) {
139139
if (fdt_device_is_available(fdt_addr, new_off)) {
140140
for (i = 0; i < drivers_count[level]; i++) {
141-
if (!strcmp(dev->compatible,
142-
driver_entries[level][i]
143-
.compatible)) {
141+
if (!strcmp(dev->compatible, driver_entries[level][i].compatible)) {
144142
found = true;
145143

146144
LOG_DEBUG("Found compatible: %s\n", driver_entries[level][i].compatible);

so3/devices/fdt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ int get_dev_info(const void *fdt_addr, int offset, const char *compat, void *inf
327327
}
328328

329329
if (prop_len > MAX_COMPAT_SIZE) {
330-
LOG_WARNING("Length of Compatible string > %d chars\n",
331-
MAX_COMPAT_SIZE);
330+
LOG_WARNING("Length of Compatible string > %d chars\n", MAX_COMPAT_SIZE);
332331
return new_offset;
333332
}
334333

so3/devices/input/ps2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ void get_mouse_state(uint8_t *packet, struct ps2_mouse *state, uint16_t max_x, u
120120
state->y = CLAMP(state->y, 0, max_y);
121121

122122
LOG_DEBUG("sign_dxy[%s, %s], dxy_val[%03u, %03u], computed_dxy[%03d, %03d]; xy[%03d, %03d]; %03s %03s %03s\n",
123-
packet[PS2_STATE] & X_BS ? "neg" : "pos", packet[PS2_STATE] & Y_BS ? "neg" : "pos", packet[PS2_X],
124-
packet[PS2_Y], GET_DX(packet[PS2_STATE], packet[PS2_X]), GET_DY(packet[PS2_STATE], packet[PS2_Y]), state->x,
125-
state->y, state->left ? "LFT" : "", state->middle ? "MID" : "", state->right ? "RGT" : "");
123+
packet[PS2_STATE] & X_BS ? "neg" : "pos", packet[PS2_STATE] & Y_BS ? "neg" : "pos", packet[PS2_X],
124+
packet[PS2_Y], GET_DX(packet[PS2_STATE], packet[PS2_X]), GET_DY(packet[PS2_STATE], packet[PS2_Y]),
125+
state->x, state->y, state->left ? "LFT" : "", state->middle ? "MID" : "", state->right ? "RGT" : "");
126126
} else {
127127
printk("%s: packet discarded.\n", __func__);
128128
}
@@ -169,5 +169,5 @@ void get_kb_key(uint8_t *packet, uint8_t len, struct ps2_key *key)
169169
}
170170

171171
LOG_DEBUG("%s sc: 0x%02x v: %c\n", key->state & KEY_ST_PRESSED ? "pressed" : "release", packet[i],
172-
key->value ? key->value : ' ');
172+
key->value ? key->value : ' ');
173173
}

so3/fs/elf.c

Lines changed: 33 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,26 @@ void elf_load_sections(elf_img_info_t *elf_img_info)
8585

8686
/* header */
8787
#ifdef CONFIG_ARCH_ARM32
88-
elf_img_info->header =
89-
(struct elf32_hdr *)malloc(sizeof(struct elf32_hdr));
88+
elf_img_info->header = (struct elf32_hdr *) malloc(sizeof(struct elf32_hdr));
9089
#else
91-
elf_img_info->header =
92-
(struct elf64_hdr *)malloc(sizeof(struct elf64_hdr));
90+
elf_img_info->header = (struct elf64_hdr *) malloc(sizeof(struct elf64_hdr));
9391
#endif
9492
if (!elf_img_info->header) {
9593
printk("%s: failed to allocate memory\n", __func__);
9694
kernel_panic();
9795
}
9896

9997
#ifdef CONFIG_ARCH_ARM32
100-
memcpy(elf_img_info->header, elf_img_info->file_buffer,
101-
sizeof(struct elf32_hdr));
98+
memcpy(elf_img_info->header, elf_img_info->file_buffer, sizeof(struct elf32_hdr));
10299
#else
103-
memcpy(elf_img_info->header, elf_img_info->file_buffer,
104-
sizeof(struct elf64_hdr));
100+
memcpy(elf_img_info->header, elf_img_info->file_buffer, sizeof(struct elf64_hdr));
105101
#endif
106102

107-
LOG_DEBUG("Magic: 0x%02x%c%c%c\n", elf_img_info->header->e_ident[EI_MAG0],
108-
elf_img_info->header->e_ident[EI_MAG1],
109-
elf_img_info->header->e_ident[EI_MAG2],
110-
elf_img_info->header->e_ident[EI_MAG3]);
103+
LOG_DEBUG("Magic: 0x%02x%c%c%c\n", elf_img_info->header->e_ident[EI_MAG0], elf_img_info->header->e_ident[EI_MAG1],
104+
elf_img_info->header->e_ident[EI_MAG2], elf_img_info->header->e_ident[EI_MAG3]);
111105
LOG_DEBUG("%d sections\n", elf_img_info->header->e_shnum);
112-
LOG_DEBUG("section table is at offset 0x%08x (%d bytes/section)\n",
113-
elf_img_info->header->e_shoff, elf_img_info->header->e_shentsize);
106+
LOG_DEBUG("section table is at offset 0x%08x (%d bytes/section)\n", elf_img_info->header->e_shoff,
107+
elf_img_info->header->e_shentsize);
114108

115109
#ifdef CONFIG_ARCH_ARM32
116110
LOG_DEBUG("sizeof(struct elf32_shdr): %d bytes\n", sizeof(struct elf32_shdr));
@@ -120,65 +114,49 @@ void elf_load_sections(elf_img_info_t *elf_img_info)
120114

121115
/* sections */
122116
#ifdef CONFIG_ARCH_ARM32
123-
elf_img_info->sections = (struct elf32_shdr *)malloc(
124-
elf_img_info->header->e_shnum * sizeof(struct elf32_shdr));
117+
elf_img_info->sections = (struct elf32_shdr *) malloc(elf_img_info->header->e_shnum * sizeof(struct elf32_shdr));
125118
#else
126-
elf_img_info->sections = (struct elf64_shdr *)malloc(
127-
elf_img_info->header->e_shnum * sizeof(struct elf64_shdr));
119+
elf_img_info->sections = (struct elf64_shdr *) malloc(elf_img_info->header->e_shnum * sizeof(struct elf64_shdr));
128120
#endif
129121

130122
if (!elf_img_info->sections) {
131123
LOG_CRITICAL("%s: failed to allocate memory\n", __func__);
132124
kernel_panic();
133125
}
134126

135-
elf_img_info->section_names =
136-
(char **)malloc(elf_img_info->header->e_shnum * sizeof(char *));
127+
elf_img_info->section_names = (char **) malloc(elf_img_info->header->e_shnum * sizeof(char *));
137128
if (!elf_img_info->section_names) {
138129
LOG_CRITICAL("%s: failed to allocate memory\n", __func__);
139130
kernel_panic();
140131
}
141132

142133
for (i = 0; i < elf_img_info->header->e_shnum; i++)
143134
memcpy(elf_img_info->sections + i,
144-
elf_img_info->file_buffer +
145-
elf_img_info->header->e_shoff +
146-
i * elf_img_info->header->e_shentsize,
135+
elf_img_info->file_buffer + elf_img_info->header->e_shoff + i * elf_img_info->header->e_shentsize,
147136
sizeof(struct elf32_shdr));
148137

149138
/* Section names */
150139
for (i = 0; i < elf_img_info->header->e_shnum; i++) {
151140
section_name_offset =
152-
elf_img_info->sections[elf_img_info->header->e_shstrndx]
153-
.sh_offset +
154-
elf_img_info->sections[i].sh_name;
155-
section_name_len =
156-
strlen((const char *)(elf_img_info->file_buffer +
157-
section_name_offset));
158-
159-
elf_img_info->section_names[i] =
160-
(char *)malloc(section_name_len + 1);
141+
elf_img_info->sections[elf_img_info->header->e_shstrndx].sh_offset + elf_img_info->sections[i].sh_name;
142+
section_name_len = strlen((const char *) (elf_img_info->file_buffer + section_name_offset));
143+
144+
elf_img_info->section_names[i] = (char *) malloc(section_name_len + 1);
161145
if (!elf_img_info->section_names[i]) {
162146
printk("%s: failed to allocate memory\n", __func__);
163147
kernel_panic();
164148
}
165149

166-
strcpy(elf_img_info->section_names[i],
167-
(char *)(elf_img_info->file_buffer +
168-
section_name_offset));
150+
strcpy(elf_img_info->section_names[i], (char *) (elf_img_info->file_buffer + section_name_offset));
169151

170-
LOG_DEBUG("[0x%08x] section name: %s\t(%d bytes)\n",
171-
section_name_offset, elf_img_info->section_names[i],
172-
section_name_len);
152+
LOG_DEBUG("[0x%08x] section name: %s\t(%d bytes)\n", section_name_offset, elf_img_info->section_names[i],
153+
section_name_len);
173154
}
174155

175156
for (i = 0; i < elf_img_info->header->e_shnum; i++) {
176-
LOG_DEBUG("\t[0x%08x] %s loads at 0x%08x (%d bytes) - flags: 0x%08x\n",
177-
elf_img_info->sections[i].sh_offset,
178-
elf_img_info->section_names[i],
179-
elf_img_info->sections[i].sh_addr,
180-
elf_img_info->sections[i].sh_size,
181-
elf_img_info->sections[i].sh_flags);
157+
LOG_DEBUG("\t[0x%08x] %s loads at 0x%08x (%d bytes) - flags: 0x%08x\n", elf_img_info->sections[i].sh_offset,
158+
elf_img_info->section_names[i], elf_img_info->sections[i].sh_addr, elf_img_info->sections[i].sh_size,
159+
elf_img_info->sections[i].sh_flags);
182160
}
183161
}
184162

@@ -188,11 +166,9 @@ void elf_load_segments(elf_img_info_t *elf_img_info)
188166

189167
/* Segments */
190168
#ifdef CONFIG_ARCH_ARM32
191-
elf_img_info->segments = (struct elf32_phdr *)malloc(
192-
sizeof(struct elf32_phdr) * elf_img_info->header->e_phnum);
169+
elf_img_info->segments = (struct elf32_phdr *) malloc(sizeof(struct elf32_phdr) * elf_img_info->header->e_phnum);
193170
#else
194-
elf_img_info->segments = (struct elf64_phdr *)malloc(
195-
sizeof(struct elf64_phdr) * elf_img_info->header->e_phnum);
171+
elf_img_info->segments = (struct elf64_phdr *) malloc(sizeof(struct elf64_phdr) * elf_img_info->header->e_phnum);
196172
#endif
197173

198174
if (!elf_img_info->segments) {
@@ -201,8 +177,8 @@ void elf_load_segments(elf_img_info_t *elf_img_info)
201177
}
202178

203179
LOG_DEBUG("%d segments\n", elf_img_info->header->e_phnum);
204-
LOG_DEBUG("segment table is at offset 0x%08x (%d bytes/section)\n",
205-
elf_img_info->header->e_phoff, elf_img_info->header->e_phentsize);
180+
LOG_DEBUG("segment table is at offset 0x%08x (%d bytes/section)\n", elf_img_info->header->e_phoff,
181+
elf_img_info->header->e_phentsize);
206182
#ifdef CONFIG_ARCH_ARM32
207183
LOG_DEBUG("sizeof(struct elf32_phdr): %d bytes\n", sizeof(struct elf32_phdr));
208184
#else
@@ -213,34 +189,23 @@ void elf_load_segments(elf_img_info_t *elf_img_info)
213189
for (i = 0; i < elf_img_info->header->e_phnum; i++) {
214190
#ifdef CONFIG_ARCH_ARM32
215191
memcpy(elf_img_info->segments + i,
216-
elf_img_info->file_buffer +
217-
elf_img_info->header->e_phoff +
218-
i * elf_img_info->header->e_phentsize,
192+
elf_img_info->file_buffer + elf_img_info->header->e_phoff + i * elf_img_info->header->e_phentsize,
219193
sizeof(struct elf32_phdr));
220194
#else
221195
memcpy(elf_img_info->segments + i,
222-
elf_img_info->file_buffer +
223-
elf_img_info->header->e_phoff +
224-
i * elf_img_info->header->e_phentsize,
196+
elf_img_info->file_buffer + elf_img_info->header->e_phoff + i * elf_img_info->header->e_phentsize,
225197
sizeof(struct elf64_phdr));
226198
#endif
227199

228200
if (elf_img_info->segments[i].p_type == PT_LOAD)
229-
elf_img_info->segment_page_count +=
230-
(elf_img_info->segments[i].p_memsz >>
231-
PAGE_SHIFT) +
232-
1;
201+
elf_img_info->segment_page_count += (elf_img_info->segments[i].p_memsz >> PAGE_SHIFT) + 1;
233202
}
234-
LOG_DEBUG("segments use %d virtual pages\n",
235-
elf_img_info->segment_page_count);
203+
LOG_DEBUG("segments use %d virtual pages\n", elf_img_info->segment_page_count);
236204

237205
for (i = 0; i < elf_img_info->header->e_phnum; i++) {
238206
LOG_DEBUG("[0x%08x] vaddr: 0x%08x; paddr: 0x%08x; filesize: 0x%08x; memsize: 0x%08x flags: 0x%08x\n",
239-
elf_img_info->segments[i].p_offset,
240-
elf_img_info->segments[i].p_vaddr,
241-
elf_img_info->segments[i].p_paddr,
242-
elf_img_info->segments[i].p_filesz,
243-
elf_img_info->segments[i].p_memsz,
244-
elf_img_info->segments[i].p_flags);
207+
elf_img_info->segments[i].p_offset, elf_img_info->segments[i].p_vaddr,
208+
elf_img_info->segments[i].p_paddr, elf_img_info->segments[i].p_filesz,
209+
elf_img_info->segments[i].p_memsz, elf_img_info->segments[i].p_flags);
245210
}
246211
}

0 commit comments

Comments
 (0)