arm:indenting

Change-Id: I2f8f664fa4c66649db8981e58e6bb7a6f533df5a
This commit is contained in:
Kees Jongenburger 2013-12-17 16:20:37 +01:00
parent 5bdd803d85
commit 46095f8bb0
13 changed files with 312 additions and 295 deletions

View File

@ -1,4 +1,3 @@
/* ARM-specific clock functions. */ /* ARM-specific clock functions. */
#include "kernel/kernel.h" #include "kernel/kernel.h"

View File

@ -51,8 +51,6 @@ struct proc *p;
} }
} }
printf("arch_do_vmctl: strange param %d\n", m_ptr->SVMCTL_PARAM); printf("arch_do_vmctl: strange param %d\n", m_ptr->SVMCTL_PARAM);
return EINVAL; return EINVAL;
} }

View File

@ -1,4 +1,3 @@
#include "kernel/kernel.h" #include "kernel/kernel.h"
#include <unistd.h> #include <unistd.h>
@ -53,7 +52,6 @@ poweroff(void)
* At this point PM should have already signaled readclock to set the alarm. * At this point PM should have already signaled readclock to set the alarm.
*/ */
if (BOARD_IS_BB(machine.board_id)) { if (BOARD_IS_BB(machine.board_id)) {
/* Powers down the SoC within 3 seconds */ /* Powers down the SoC within 3 seconds */
direct_print("PMIC Power-Off in 3 Seconds\n"); direct_print("PMIC Power-Off in 3 Seconds\n");

View File

@ -46,11 +46,12 @@ void arch_proc_reset(struct proc *pr)
/* Clear process state. */ /* Clear process state. */
memset(&pr->p_reg, 0, sizeof(pr->p_reg)); memset(&pr->p_reg, 0, sizeof(pr->p_reg));
if(iskerneln(pr->p_nr)) if(iskerneln(pr->p_nr)) {
pr->p_reg.psr = INIT_TASK_PSR; pr->p_reg.psr = INIT_TASK_PSR;
else } else {
pr->p_reg.psr = INIT_PSR; pr->p_reg.psr = INIT_PSR;
} }
}
void arch_proc_setcontext(struct proc *p, struct stackframe_s *state, void arch_proc_setcontext(struct proc *p, struct stackframe_s *state,
int isuser, int trapstyle) int isuser, int trapstyle)

View File

@ -45,7 +45,6 @@ void omap3_irq_handle(void) {
irq_handle(irq); irq_handle(irq);
/* re-enable. this should not trigger interrupts due to current cpsr state */ /* re-enable. this should not trigger interrupts due to current cpsr state */
mmio_write(omap_intr.base + OMAP3_INTCPS_CONTROL,OMAP3_INTR_NEWIRQAGR); mmio_write(omap_intr.base + OMAP3_INTCPS_CONTROL,OMAP3_INTR_NEWIRQAGR);
} }
void omap3_irq_unmask(int irq) void omap3_irq_unmask(int irq)

View File

@ -24,7 +24,7 @@ struct omap_padconf
}; };
struct omap_padconf omap_padconfs[] = { static struct omap_padconf omap_padconfs[] = {
{ {
.base = PADCONF_DM37XX_REGISTERS_BASE, .base = PADCONF_DM37XX_REGISTERS_BASE,
.offset = PADCONF_DM37XX_REGISTERS_OFFSET, .offset = PADCONF_DM37XX_REGISTERS_OFFSET,

View File

@ -37,7 +37,6 @@ static kern_phys_map reset_phys_map;
void void
omap3_reset_init(void) omap3_reset_init(void)
{ {
if(BOARD_IS_BBXM(machine.board_id)) { if(BOARD_IS_BBXM(machine.board_id)) {
omap_reset.base = DM37XX_CM_BASE; omap_reset.base = DM37XX_CM_BASE;
omap_reset.size = DM37XX_CM_SIZE; omap_reset.size = DM37XX_CM_SIZE;

View File

@ -51,7 +51,6 @@ void omap3_ser_init()
} }
omap_serial.size = 0x1000 ; /* 4k */ omap_serial.size = 0x1000 ; /* 4k */
kern_phys_map_ptr(omap_serial.base,omap_serial.size, kern_phys_map_ptr(omap_serial.base,omap_serial.size,
&serial_phys_map, (vir_bytes) &omap_serial.base); &serial_phys_map, (vir_bytes) &omap_serial.base);
assert(omap_serial.base); assert(omap_serial.base);
@ -59,20 +58,23 @@ void omap3_ser_init()
void omap3_ser_putc(char c) void omap3_ser_putc(char c)
{ {
int i;
assert(omap_serial.base); assert(omap_serial.base);
int i;
/* Wait until FIFO's empty */ /* Wait until FIFO's empty */
for (i = 0; i < 100000; i++) for (i = 0; i < 100000; i++) {
if (mmio_read(omap_serial.base + OMAP3_LSR) & OMAP3_LSR_THRE) if (mmio_read(omap_serial.base + OMAP3_LSR) & OMAP3_LSR_THRE) {
break; break;
}
}
/* Write character */ /* Write character */
mmio_write(omap_serial.base + OMAP3_THR, c); mmio_write(omap_serial.base + OMAP3_THR, c);
/* And wait again until FIFO's empty to prevent TTY from overwriting */ /* And wait again until FIFO's empty to prevent TTY from overwriting */
for (i = 0; i < 100000; i++) for (i = 0; i < 100000; i++) {
if (mmio_read(omap_serial.base + OMAP3_LSR) & (OMAP3_LSR_THRE | OMAP3_LSR_TEMT)) if (mmio_read(omap_serial.base + OMAP3_LSR) & (OMAP3_LSR_THRE | OMAP3_LSR_TEMT)) {
break; break;
} }
}
}

View File

@ -12,7 +12,8 @@
#include "omap_timer.h" #include "omap_timer.h"
#include "omap_intr.h" #include "omap_intr.h"
static irq_hook_t omap3_timer_hook; /* interrupt handler hook */ /* interrupt handler hook */
static irq_hook_t omap3_timer_hook;
static u64_t high_frc; static u64_t high_frc;
struct omap_timer_registers; struct omap_timer_registers;
@ -195,7 +196,8 @@ void omap3_frclock_init(void)
/* Set up overflow interrupt */ /* Set up overflow interrupt */
tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG | tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG |
OMAP3_TISR_TCAR_IT_FLAG; OMAP3_TISR_TCAR_IT_FLAG;
mmio_write(fr_timer->base + fr_timer->regs->TISR, tisr); /* Clear interrupt status */ /* Clear interrupt status */
mmio_write(fr_timer->base + fr_timer->regs->TISR, tisr);
mmio_write(fr_timer->base + fr_timer->regs->TIER, OMAP3_TIER_OVF_IT_ENA); mmio_write(fr_timer->base + fr_timer->regs->TIER, OMAP3_TIER_OVF_IT_ENA);
/* Start timer */ /* Start timer */
@ -253,7 +255,8 @@ void omap3_timer_init(unsigned freq)
/* Set up overflow interrupt */ /* Set up overflow interrupt */
tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG | tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG |
OMAP3_TISR_TCAR_IT_FLAG; OMAP3_TISR_TCAR_IT_FLAG;
mmio_write(timer->base + timer->regs->TISR, tisr); /* Clear interrupt status */ /* Clear interrupt status */
mmio_write(timer->base + timer->regs->TISR, tisr);
mmio_write(timer->base + timer->regs->TIER, OMAP3_TIER_OVF_IT_ENA); mmio_write(timer->base + timer->regs->TIER, OMAP3_TIER_OVF_IT_ENA);
/* Start timer */ /* Start timer */
@ -268,8 +271,9 @@ void omap3_timer_stop()
static u32_t read_frc(void) static u32_t read_frc(void)
{ {
if (done == 0) if (done == 0) {
return 0; return 0;
}
return mmio_read(fr_timer->base + fr_timer->regs->TCRR); return mmio_read(fr_timer->base + fr_timer->regs->TCRR);
} }
@ -291,8 +295,9 @@ static void frc_overflow_check(u32_t cur_frc)
{ {
static int prev_frc_valid; static int prev_frc_valid;
static u32_t prev_frc; static u32_t prev_frc;
if(prev_frc_valid && prev_frc > cur_frc) if(prev_frc_valid && prev_frc > cur_frc) {
high_frc++; high_frc++;
}
prev_frc = cur_frc; prev_frc = cur_frc;
prev_frc_valid = 1; prev_frc_valid = 1;
} }
@ -305,8 +310,7 @@ void omap3_timer_int_handler()
/* when the kernel itself is running interrupts are disabled. /* when the kernel itself is running interrupts are disabled.
* We should therefore also read the overflow counter to detect * We should therefore also read the overflow counter to detect
* this as to not miss events. * this as to not miss events. */
*/
tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG | tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG |
OMAP3_TISR_TCAR_IT_FLAG; OMAP3_TISR_TCAR_IT_FLAG;
mmio_write(timer->base + timer->regs->TISR, tisr); mmio_write(timer->base + timer->regs->TISR, tisr);

View File

@ -1,4 +1,3 @@
#include <minix/cpufeature.h> #include <minix/cpufeature.h>
#include <minix/type.h> #include <minix/type.h>
@ -72,12 +71,18 @@ void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len)
/* Truncate available memory at 4GB as the rest of minix /* Truncate available memory at 4GB as the rest of minix
* currently can't deal with any bigger. * currently can't deal with any bigger.
*/ */
if(addr > LIMIT) return; if(addr > LIMIT) {
return;
}
if(addr + len > LIMIT) { if(addr + len > LIMIT) {
len -= (addr + len - LIMIT); len -= (addr + len - LIMIT);
} }
assert(cbi->mmap_size < MAXMEMMAP); assert(cbi->mmap_size < MAXMEMMAP);
if(len == 0) return; if(len == 0) {
return;
}
addr = roundup(addr, ARM_PAGE_SIZE); addr = roundup(addr, ARM_PAGE_SIZE);
len = rounddown(len, ARM_PAGE_SIZE); len = rounddown(len, ARM_PAGE_SIZE);
@ -85,17 +90,19 @@ void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len)
for(m = 0; m < MAXMEMMAP; m++) { for(m = 0; m < MAXMEMMAP; m++) {
phys_bytes highmark; phys_bytes highmark;
if(cbi->memmap[m].len) continue; if(cbi->memmap[m].len) {
continue;
}
cbi->memmap[m].addr = addr; cbi->memmap[m].addr = addr;
cbi->memmap[m].len = len; cbi->memmap[m].len = len;
cbi->memmap[m].type = MULTIBOOT_MEMORY_AVAILABLE; cbi->memmap[m].type = MULTIBOOT_MEMORY_AVAILABLE;
if(m >= cbi->mmap_size) if(m >= cbi->mmap_size) {
cbi->mmap_size = m+1; cbi->mmap_size = m+1;
}
highmark = addr + len; highmark = addr + len;
if(highmark > cbi->mem_high_phys) { if(highmark > cbi->mem_high_phys) {
cbi->mem_high_phys = highmark; cbi->mem_high_phys = highmark;
} }
return; return;
} }
@ -108,7 +115,9 @@ u32_t *alloc_pagetable(phys_bytes *ph)
#define PG_PAGETABLES 24 #define PG_PAGETABLES 24
static u32_t pagetables[PG_PAGETABLES][256] __aligned(1024); static u32_t pagetables[PG_PAGETABLES][256] __aligned(1024);
static int pt_inuse = 0; static int pt_inuse = 0;
if(pt_inuse >= PG_PAGETABLES) panic("no more pagetables"); if(pt_inuse >= PG_PAGETABLES) {
panic("no more pagetables");
}
assert(sizeof(pagetables[pt_inuse]) == 1024); assert(sizeof(pagetables[pt_inuse]) == 1024);
ret = pagetables[pt_inuse++]; ret = pagetables[pt_inuse++];
*ph = vir2phys(ret); *ph = vir2phys(ret);
@ -126,7 +135,9 @@ phys_bytes pg_alloc_page(kinfo_t *cbi)
for(m = 0; m < cbi->mmap_size; m++) { for(m = 0; m < cbi->mmap_size; m++) {
mmap = &cbi->memmap[m]; mmap = &cbi->memmap[m];
if(!mmap->len) continue; if(!mmap->len) {
continue;
}
assert(mmap->len > 0); assert(mmap->len > 0);
assert(!(mmap->len % ARM_PAGE_SIZE)); assert(!(mmap->len % ARM_PAGE_SIZE));
assert(!(mmap->addr % ARM_PAGE_SIZE)); assert(!(mmap->addr % ARM_PAGE_SIZE));
@ -243,8 +254,9 @@ void pg_clear(void)
phys_bytes pg_rounddown(phys_bytes b) phys_bytes pg_rounddown(phys_bytes b)
{ {
phys_bytes o; phys_bytes o;
if(!(o = b % ARM_PAGE_SIZE)) if(!(o = b % ARM_PAGE_SIZE)) {
return b; return b;
}
return b - o; return b - o;
} }
@ -291,10 +303,11 @@ void pg_map(phys_bytes phys, vir_bytes vaddr, vir_bytes vaddr_end,
| ARM_VM_PTE_CACHED | ARM_VM_PTE_CACHED
| ARM_VM_PTE_USER; | ARM_VM_PTE_USER;
vaddr += ARM_PAGE_SIZE; vaddr += ARM_PAGE_SIZE;
if(phys != PG_ALLOCATEME) if(phys != PG_ALLOCATEME) {
phys += ARM_PAGE_SIZE; phys += ARM_PAGE_SIZE;
} }
} }
}
void pg_info(reg_t *pagedir_ph, u32_t **pagedir_v) void pg_info(reg_t *pagedir_ph, u32_t **pagedir_v)
{ {

View File

@ -1,4 +1,3 @@
#define UNPAGED 1 /* for proper kmain() prototype */ #define UNPAGED 1 /* for proper kmain() prototype */
#include "kernel/kernel.h" #include "kernel/kernel.h"
@ -143,8 +142,9 @@ static int mb_set_param(char *bigbuf,char *name,char *value, kinfo_t *cbi)
if (p > bigbuf) p++; if (p > bigbuf) p++;
/* Make sure there's enough space for the new parameter */ /* Make sure there's enough space for the new parameter */
if (p + namelen + valuelen + 3 > bufend) if (p + namelen + valuelen + 3 > bufend) {
return -1; return -1;
}
strcpy(p, name); strcpy(p, name);
p[namelen] = '='; p[namelen] = '=';
@ -165,9 +165,10 @@ int overlaps(multiboot_module_t *mod, int n, int cmp_mod)
for(m = 0; m < n; m++) { for(m = 0; m < n; m++) {
multiboot_module_t *thismod = &mod[m]; multiboot_module_t *thismod = &mod[m];
if(m == cmp_mod) continue; if(m == cmp_mod) continue;
if(OVERLAP(thismod, cmp)) if(OVERLAP(thismod, cmp)) {
return 1; return 1;
} }
}
return 0; return 0;
} }
@ -255,8 +256,9 @@ void get_parameters(kinfo_t *cbi, char *bootargs)
var[var_i++] = *p++ ; var[var_i++] = *p++ ;
var[var_i] = 0; var[var_i] = 0;
if (*p++ != '=') continue; /* skip if not name=value */ if (*p++ != '=') continue; /* skip if not name=value */
while (*p && *p != ' ' && value_i < BUF - 1) while (*p && *p != ' ' && value_i < BUF - 1) {
value[value_i++] = *p++ ; value[value_i++] = *p++ ;
}
value[value_i] = 0; value[value_i] = 0;
mb_set_param(cbi->param_buf, var, value, cbi); mb_set_param(cbi->param_buf, var, value, cbi);
@ -380,6 +382,7 @@ kinfo_t *pre_init(int argc, char **argv)
if (argc != 2) { if (argc != 2) {
POORMANS_FAILURE_NOTIFICATION; POORMANS_FAILURE_NOTIFICATION;
} }
bootargs = argv[1]; bootargs = argv[1];
set_machine_id(bootargs); set_machine_id(bootargs);
omap3_ser_init(); omap3_ser_init();

View File

@ -22,7 +22,8 @@ int prot_init_done = 0;
phys_bytes vir2phys(void *vir) phys_bytes vir2phys(void *vir)
{ {
extern char _kern_vir_base, _kern_phys_base; /* in kernel.lds */ /* defined in kernel.lds */
extern char _kern_vir_base, _kern_phys_base;
u32_t offset = (vir_bytes) &_kern_vir_base - u32_t offset = (vir_bytes) &_kern_vir_base -
(vir_bytes) &_kern_phys_base; (vir_bytes) &_kern_phys_base;
return (phys_bytes)vir - offset; return (phys_bytes)vir - offset;