Some KNF.

This commit is contained in:
tsutsui 2009-03-05 13:42:59 +00:00
parent 30b8022325
commit 50dbef0dcb
2 changed files with 138 additions and 128 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: atari_init.c,v 1.74 2009/03/05 13:21:44 tsutsui Exp $ */
/* $NetBSD: atari_init.c,v 1.75 2009/03/05 13:42:59 tsutsui Exp $ */
/*
* Copyright (c) 1995 Leo Weppelman
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.74 2009/03/05 13:21:44 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.75 2009/03/05 13:42:59 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_mbtype.h"
@ -175,10 +175,10 @@ int kernel_copyback = 1;
void
start_c(id, ttphystart, ttphysize, stphysize, esym_addr)
int id; /* Machine id */
u_int ttphystart, ttphysize; /* Start address and size of TT-ram */
u_int stphysize; /* Size of ST-ram */
char *esym_addr; /* Address of kernel '_esym' symbol */
int id; /* Machine id */
u_int ttphystart, ttphysize; /* Start address and size of TT-ram */
u_int stphysize; /* Size of ST-ram */
char *esym_addr; /* Address of kernel '_esym' symbol */
{
extern char end[];
extern void etext(void);
@ -233,7 +233,7 @@ char *esym_addr; /* Address of kernel '_esym' symbol */
/*
* the kernel ends at end() or esym.
*/
if(esym == NULL)
if (esym == NULL)
end_loaded = (vaddr_t)&end;
else
end_loaded = (vaddr_t)esym;
@ -242,7 +242,7 @@ char *esym_addr; /* Address of kernel '_esym' symbol */
* If we have enough fast-memory to put the kernel in and the
* RELOC_KERNEL option is set, do it!
*/
if((reloc_kernel != 0) && (ttphysize >= end_loaded))
if ((reloc_kernel != 0) && (ttphysize >= end_loaded))
kbase = ttphystart;
else
kbase = 0;
@ -434,7 +434,7 @@ char *esym_addr; /* Address of kernel '_esym' symbol */
pg = &pg[vstart / PAGE_SIZE];
pg_proto = st_pool_phys | PG_RW | PG_CI | PG_V;
vstart += st_pool_size;
while(pg_proto < (st_pool_phys + st_pool_size)) {
while (pg_proto < (st_pool_phys + st_pool_size)) {
*pg++ = pg_proto;
pg_proto += PAGE_SIZE;
}
@ -474,7 +474,7 @@ char *esym_addr; /* Address of kernel '_esym' symbol */
usable_segs[1].end = ttphystart + ttphysize;
usable_segs[2].start = usable_segs[2].end = 0; /* End of segments! */
if(kbase) {
if (kbase) {
/*
* First page of ST-ram is unusable, reserve the space
* for the kernel in the TT-ram segment.
@ -483,8 +483,7 @@ char *esym_addr; /* Address of kernel '_esym' symbol */
*/
usable_segs[0].start = PAGE_SIZE;
usable_segs[1].start += pstart;
}
else
} else
usable_segs[0].start += pstart;
/*
@ -520,7 +519,7 @@ char *esym_addr; /* Address of kernel '_esym' symbol */
* to fastram. DONT use bcopy(), this beast is much larger
* than 128k !
*/
if(kbase) {
if (kbase) {
register paddr_t *lp, *le, *fp;
lp = (paddr_t *)0;
@ -605,10 +604,10 @@ char *esym_addr; /* Address of kernel '_esym' symbol */
*/
for (i = 0; boot_segs[i].end != 0; i++) {
if (extent_alloc_region(iomem_ex, boot_segs[i].start,
boot_segs[i].end - boot_segs[i].start, EX_NOWAIT)) {
boot_segs[i].end - boot_segs[i].start, EX_NOWAIT)) {
/* XXX: Ahum, should not happen ;-) */
printf("Warning: Cannot allocate boot memory from"
" extent map!?\n");
" extent map!?\n");
}
}
@ -623,33 +622,36 @@ char *esym_addr; /* Address of kernel '_esym' symbol */
* Note: This module runs *before* the io-mapping is setup!
*/
static void
set_machtype()
set_machtype(void)
{
#ifdef _MILANHW_
machineid |= ATARI_MILAN;
#else
stio_addr = 0xff8000; /* XXX: For TT & Falcon only */
if(badbaddr((void *)__UNVOLATILE(&MFP2->mf_gpip), sizeof(char))) {
if (badbaddr((void *)__UNVOLATILE(&MFP2->mf_gpip), sizeof(char))) {
/*
* Watch out! We can also have a Hades with < 16Mb
* RAM here...
*/
if(!badbaddr((void *)__UNVOLATILE(&MFP->mf_gpip),
sizeof(char))) {
if (!badbaddr((void *)__UNVOLATILE(&MFP->mf_gpip),
sizeof(char))) {
machineid |= ATARI_FALCON;
return;
}
}
if(!badbaddr((void *)(PCI_CONFB_PHYS + PCI_CONFM_PHYS), sizeof(char)))
if (!badbaddr((void *)(PCI_CONFB_PHYS + PCI_CONFM_PHYS), sizeof(char)))
machineid |= ATARI_HADES;
else machineid |= ATARI_TT;
else
machineid |= ATARI_TT;
#endif /* _MILANHW_ */
}
static void
atari_hwinit()
atari_hwinit(void)
{
#if defined(_ATARIHW_)
/*
* Initialize the sound chip
@ -677,14 +679,14 @@ atari_hwinit()
MFP->mf_vr = 0x40;
#if defined(_ATARIHW_)
if(machineid & (ATARI_TT|ATARI_HADES)) {
if (machineid & (ATARI_TT|ATARI_HADES)) {
MFP2->mf_iera = MFP2->mf_ierb = 0;
MFP2->mf_imra = MFP2->mf_imrb = 0;
MFP2->mf_aer = 0x80;
MFP2->mf_vr = 0x50;
}
if(machineid & ATARI_TT) {
if (machineid & ATARI_TT) {
/*
* Initialize the SCU, to enable interrupts on the SCC (ipl5),
* MFP (ipl6) and softints (ipl1).
@ -702,7 +704,7 @@ atari_hwinit()
#endif /* defined(_ATARIHW_) */
#if NPCI > 0
if(machineid & (ATARI_HADES|ATARI_MILAN)) {
if (machineid & (ATARI_HADES|ATARI_MILAN)) {
/*
* Configure PCI-bus
*/
@ -768,10 +770,10 @@ map_io_areas(ptpa, ptsize, ptextra)
epg = &pg[btoc(PCI_CONF_SIZE)];
mask = PCI_CONFM_PHYS;
pg_proto = PCI_CONFB_PHYS | PG_RW | PG_CI | PG_V;
for(; pg < epg; mask <<= 1)
for (; pg < epg; mask <<= 1)
*pg++ = pg_proto | mask;
}
else pci_conf_addr = 0; /* XXX: should crash */
} else
pci_conf_addr = 0; /* XXX: should crash */
if (machineid & (ATARI_HADES|ATARI_MILAN)) {
pci_io_addr = ioaddr;
@ -779,7 +781,7 @@ map_io_areas(ptpa, ptsize, ptextra)
pg = &pt[pci_io_addr / PAGE_SIZE];
epg = &pg[btoc(PCI_IO_SIZE)];
pg_proto = PCI_IO_PHYS | PG_RW | PG_CI | PG_V;
while(pg < epg) {
while (pg < epg) {
*pg++ = pg_proto;
pg_proto += PAGE_SIZE;
}
@ -790,7 +792,7 @@ map_io_areas(ptpa, ptsize, ptextra)
ioaddr += PCI_MEM_SIZE;
epg = &pg[btoc(PCI_MEM_SIZE)];
pg_proto = PCI_VGA_PHYS | PG_RW | PG_CI | PG_V;
while(pg < epg) {
while (pg < epg) {
*pg++ = pg_proto;
pg_proto += PAGE_SIZE;
}
@ -812,7 +814,7 @@ map_io_areas(ptpa, ptsize, ptextra)
#define MDHDRSIZE roundup(CHDRSIZE, dbtob(1))
int
cpu_dumpsize()
cpu_dumpsize(void)
{
return btodb(MDHDRSIZE);
@ -1078,7 +1080,7 @@ int m68060_pcr_init = 0x21; /* make this patchable */
#endif
static void
initcpu()
initcpu(void)
{
typedef void trapfun(void);
@ -1204,9 +1206,10 @@ u_int
vmtophys(ste, vm)
u_int *ste, vm;
{
ste = (u_int *) (*(ste + (vm >> SEGSHIFT)) & SG_FRAME);
ste += (vm & SG_PMASK) >> PGSHIFT;
return((*ste & -PAGE_SIZE) | (vm & (PAGE_SIZE - 1)));
ste = (u_int *)(*(ste + (vm >> SEGSHIFT)) & SG_FRAME);
ste += (vm & SG_PMASK) >> PGSHIFT;
return (*ste & -PAGE_SIZE) | (vm & (PAGE_SIZE - 1));
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.159 2009/02/13 22:41:01 apb Exp $ */
/* $NetBSD: machdep.c,v 1.160 2009/03/05 13:42:59 tsutsui Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.159 2009/02/13 22:41:01 apb Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.160 2009/03/05 13:42:59 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@ -212,7 +212,7 @@ consinit(void)
}
#endif
#if defined (DDB)
if(boothowto & RB_KDB)
if (boothowto & RB_KDB)
Debugger();
#endif
}
@ -256,14 +256,13 @@ cpu_startup(void)
* Allocate a submap for physio
*/
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
VM_PHYS_SIZE, 0, false, NULL);
VM_PHYS_SIZE, 0, false, NULL);
/*
* Finally, allocate mbuf cluster submap.
*/
mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
nmbclusters * mclbytes, VM_MAP_INTRSAFE,
false, NULL);
nmbclusters * mclbytes, VM_MAP_INTRSAFE, false, NULL);
#ifdef DEBUG
pmapdebug = opmapdebug;
@ -321,21 +320,21 @@ identifycpu(void)
const char *mach, *mmu, *fpu, *cpu;
switch (machineid & ATARI_ANYMACH) {
case ATARI_TT:
mach = "Atari TT";
break;
case ATARI_FALCON:
mach = "Atari Falcon";
break;
case ATARI_HADES:
mach = "Atari Hades";
break;
case ATARI_MILAN:
mach = "Atari Milan";
break;
default:
mach = "Atari UNKNOWN";
break;
case ATARI_TT:
mach = "Atari TT";
break;
case ATARI_FALCON:
mach = "Atari Falcon";
break;
case ATARI_HADES:
mach = "Atari Hades";
break;
case ATARI_MILAN:
mach = "Atari Milan";
break;
default:
mach = "Atari UNKNOWN";
break;
}
cpu = "m68k";
@ -344,7 +343,7 @@ identifycpu(void)
switch (cputype) {
case CPU_68060:
case CPU_68060:
{
u_int32_t pcr;
char cputxt[30];
@ -397,6 +396,7 @@ static int waittime = -1;
static void
bootsync(void)
{
if (waittime < 0) {
waittime = 0;
@ -413,12 +413,13 @@ bootsync(void)
void
cpu_reboot(int howto, char *bootstr)
{
/* take a snap shot before clobbering any registers */
if (curlwp->l_addr)
savectx(&curlwp->l_addr->u_pcb);
boothowto = howto;
if((howto & RB_NOSYNC) == 0)
if ((howto & RB_NOSYNC) == 0)
bootsync();
/*
@ -430,12 +431,11 @@ cpu_reboot(int howto, char *bootstr)
pmf_system_shutdown(boothowto);
splhigh(); /* extreme priority */
if(howto & RB_HALT) {
if (howto & RB_HALT) {
printf("halted\n\n");
__asm(" stop #0x2700");
}
else {
if(howto & RB_DUMP)
} else {
if (howto & RB_DUMP)
dumpsys();
doboot();
@ -454,8 +454,9 @@ static vaddr_t dumpspace; /* Virt. space to map dumppages */
vaddr_t
reserve_dumppages(vaddr_t p)
{
dumpspace = p;
return(p + BYTES_PER_DUMP);
return p + BYTES_PER_DUMP;
}
u_int32_t dumpmag = 0x8fca0101; /* magic number for savecore */
@ -541,13 +542,13 @@ dumpsys(void)
printf("Do you want to dump memory? [y]");
cnputc(i = cngetc());
switch (i) {
case 'n':
case 'N':
return;
case '\n':
break;
default :
cnputc('\n');
case 'n':
case 'N':
return;
case '\n':
break;
default :
cnputc('\n');
}
#endif /* defined(DDB) || defined(PANICWAIT) */
@ -561,41 +562,44 @@ dumpsys(void)
error = cpu_dump(dump, &blkno);
if (!error) {
for (i = 0; i < nbytes; i += n, segbytes -= n) {
/*
* Skip the hole
*/
if (segbytes == 0) {
segnum++;
maddr = boot_segs[segnum].start;
segbytes = boot_segs[segnum].end - boot_segs[segnum].start;
for (i = 0; i < nbytes; i += n, segbytes -= n) {
/*
* Skip the hole
*/
if (segbytes == 0) {
segnum++;
maddr = boot_segs[segnum].start;
segbytes = boot_segs[segnum].end -
boot_segs[segnum].start;
}
/*
* Print Mb's to go
*/
n = nbytes - i;
if (n && (n % (1024*1024)) == 0)
printf_nolog("%d ", n / (1024 * 1024));
/*
* Limit transfer to BYTES_PER_DUMP
*/
if (n > BYTES_PER_DUMP)
n = BYTES_PER_DUMP;
/*
* Map to a VA and write it
*/
if (maddr != 0) { /* XXX kvtop chokes on this */
(void)pmap_map(dumpspace, maddr, maddr + n,
VM_PROT_READ);
error = (*dump)(dumpdev, blkno,
(void *)dumpspace, n);
if (error)
break;
}
maddr += n;
blkno += btodb(n);
}
/*
* Print Mb's to go
*/
n = nbytes - i;
if (n && (n % (1024*1024)) == 0)
printf_nolog("%d ", n / (1024 * 1024));
/*
* Limit transfer to BYTES_PER_DUMP
*/
if (n > BYTES_PER_DUMP)
n = BYTES_PER_DUMP;
/*
* Map to a VA and write it
*/
if (maddr != 0) { /* XXX kvtop chokes on this */
(void)pmap_map(dumpspace, maddr, maddr+n, VM_PROT_READ);
error = (*dump)(dumpdev, blkno, (void *)dumpspace, n);
if (error)
break;
}
maddr += n;
blkno += btodb(n);
}
}
switch (error) {
@ -629,7 +633,7 @@ straytrap(int pc, u_short evec)
static int prev_evec;
printf("unexpected trap (vector offset 0x%x) from 0x%x\n",
evec & 0xFFF, pc);
evec & 0xFFF, pc);
if(prev_evec == evec) {
delay(1000000);
@ -641,6 +645,7 @@ straytrap(int pc, u_short evec)
void
straymfpint(int pc, u_short evec)
{
printf("unexpected mfp-interrupt (vector offset 0x%x) from 0x%x\n",
evec & 0xFFF, pc);
}
@ -659,23 +664,23 @@ badbaddr(void *addr, int size)
nofault = (int *) &faultbuf;
if (setjmp((label_t *)nofault)) {
nofault = (int *) 0;
return(1);
return 1;
}
switch (size) {
case 1:
i = *(volatile char *)addr;
break;
case 2:
i = *(volatile short *)addr;
break;
case 4:
i = *(volatile long *)addr;
break;
default:
panic("badbaddr: unknown size");
case 1:
i = *(volatile char *)addr;
break;
case 2:
i = *(volatile short *)addr;
break;
case 4:
i = *(volatile long *)addr;
break;
default:
panic("badbaddr: unknown size");
}
nofault = (int *) 0;
return(0);
return 0;
}
/*
@ -722,17 +727,17 @@ add_sicallback(void (*function)(void *, void *), void *rock1, void *rock2)
* We may NOT block for memory-allocation in here!.
*/
s = splhigh();
if((si = si_free) != NULL)
if ((si = si_free) != NULL)
si_free = si->next;
splx(s);
if(si == NULL) {
si = (struct si_callback *)malloc(sizeof(*si),M_TEMP,M_NOWAIT);
si = malloc(sizeof(*si), M_TEMP, M_NOWAIT);
#ifdef DIAGNOSTIC
if(si)
if (si)
++ncbd; /* count # dynamically allocated */
#endif
if(!si)
if (!si)
return;
}
@ -768,17 +773,18 @@ rem_sicallback(void (*function)(void *rock1, void *rock2))
int s;
s = splhigh();
for(psi = 0, si = si_callbacks; si; ) {
for (psi = 0, si = si_callbacks; si; ) {
nsi = si->next;
if(si->function != function)
if (si->function != function)
psi = si;
else {
si->next = si_free;
si_free = si;
if(psi)
if (psi)
psi->next = nsi;
else si_callbacks = nsi;
else
si_callbacks = nsi;
}
si = nsi;
}
@ -805,7 +811,7 @@ call_sicallbacks(void)
rock1 = si->rock1;
rock2 = si->rock2;
s = splhigh ();
if(si_callbacks)
if (si_callbacks)
softint_schedule(si_callback_cookie);
si->next = si_free;
si_free = si;
@ -850,6 +856,7 @@ void candbtimer(void);
void
candbtimer(void)
{
crashandburn = 0;
}
#endif
@ -873,7 +880,7 @@ cpu_exec_aout_makecmds(struct lwp *l, struct exec_package *epp)
&& execp->a_midmag == ZMAGIC)
return(exec_aout_prep_zmagic(l->l_proc, epp));
#endif
return(error);
return error;
}
#ifdef _MILANHW_