fix code so that a 'generic' OFW kernel (which only uses OFW drivers)

will again compile.  This code needs a bunch of cleanup, and the
"generic OFW kernel" code should probably be split into a different
directory than the code which implements the interface to OFW.
This commit is contained in:
cgd 1998-05-22 17:43:10 +00:00
parent 53f0465917
commit a2c213c028
4 changed files with 75 additions and 218 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ofw.c,v 1.3 1998/05/01 21:18:43 cgd Exp $ */
/* $NetBSD: ofw.c,v 1.4 1998/05/22 17:43:10 cgd Exp $ */
/*
* Copyright 1997
@ -644,6 +644,7 @@ ofw_getcleaninfo()
return pclean;
}
#ifdef DMA_BOUNCE /* XXX */
/* hack, hack, hack, your DMA,
gently into the kernel.
merrily, merrily, merrily, merrily,
@ -711,6 +712,7 @@ vm_offset_t ofw_getisadmamemory(size, align)
return -1; /* uh, oh. */
}
#endif /* DMA_BOUNCE XXX */
void
ofw_configisa(vm_offset_t *pio, vm_offset_t *pmem)
@ -840,11 +842,13 @@ ofw_configisadma(vm_offset_t *pdma)
}
#endif
#ifdef DMA_BOUNCE /* XXX */
/* XXX - Snarf physical memory for DMA bounce buffers. */
if ((*pdma =
ofw_getisadmamemory(DMA_BOUNCE * NBPG, DMA_BOUNCE * NBPG)) == -1)
panic("no ISA DMA memory: is memory populated in the correct slot?");
#endif /* DMA_BOUNCE XXX */
}
int
@ -1222,9 +1226,56 @@ ofw_callbackhandler(args)
args->nreturns = 4;
}
} else if (strcmp(name, "claim-phys") == 0) {
printf("unimplemented ofw callback - %s\n", name);
args_n_results[nargs] = -1;
args->nreturns = 1;
struct pglist alloclist = TAILQ_HEAD_INITIALIZER(alloclist);
vm_offset_t low, high;
vm_size_t align, size;
/*
* XXX
* XXX THIS IS A GROSS HACK AND NEEDS TO BE REWRITTEN. -- cgd
* XXX
*/
/* Check format. */
if (nargs != 4 || nreturns < 3) {
args_n_results[nargs] = -1;
args->nreturns = 1;
return;
}
args_n_results[nargs] = 0; /* properly formatted request */
low = args_n_results[0];
size = args_n_results[2];
align = args_n_results[3];
high = args_n_results[1] + size;
#if 0
printf("claim-phys: low = 0x%x, size = 0x%x, align = 0x%x, high = 0x%x\n",
low, size, align, high);
align = size;
printf("forcing align to be 0x%x\n", align);
#endif
args_n_results[nargs + 1] =
vm_page_alloc_memory(size, low, high, align, 0, &alloclist,
1, 0);
#if 0
printf(" -> 0x%lx", args_n_results[nargs + 1]);
#endif
if (args_n_results[nargs + 1] != 0) {
#if 0
printf("(failed)\n");
#endif
args_n_results[nargs + 1] = -1;
args->nreturns = 2;
return;
}
args_n_results[nargs + 2] = alloclist.tqh_first->phys_addr;
#if 0
printf("(succeeded: pa = 0x%lx)\n", args_n_results[nargs + 2]);
#endif
args->nreturns = 3;
} else if (strcmp(name, "release-phys") == 0) {
printf("unimplemented ofw callback - %s\n", name);
args_n_results[nargs] = -1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ofw_irq.S,v 1.2 1998/05/01 21:13:58 cgd Exp $ */
/* $NetBSD: ofw_irq.S,v 1.3 1998/05/22 17:43:11 cgd Exp $ */
/*
* Copyright (c) 1994-1997 Mark Brinicombe.
@ -173,13 +173,13 @@ irq_entry:
/* mov r11, #0x00000000*/ /* Trace back stops here */
/*
* Can't field this interrupt now if priority is SPL_CLOCK
* Can't field this interrupt now if priority is _SPL_CLOCK
* or higher. For now, we'll just ignore the interrupt.
* Soon, we will have to schedule it for later action.
*/
ldr r0, Lcurrent_spl_level
ldr r0, [r0]
cmp r0, #SPL_CLOCK
cmp r0, #_SPL_CLOCK
blt ofwtakeint
PULLFRAMEFROMSVCANDEXIT

View File

@ -1,4 +1,4 @@
/* $NetBSD: ofwgencfg_clock.c,v 1.2 1998/05/01 21:18:43 cgd Exp $ */
/* $NetBSD: ofwgencfg_clock.c,v 1.3 1998/05/22 17:43:11 cgd Exp $ */
/*
* Copyright 1997
@ -195,210 +195,3 @@ need_proftick(p)
struct proc *p;
{
}
/*
* Time-of-day clock
*
* Cribbed from dev/todclock.c
* Need to integrate with that code!
*/
#include <machine/rtc.h>
static rtc_t fake_rtc = {0, 0, 0, 0, 0, 11, 3, 97, 19}; /* March 11, 1997, 00:00:00 */
static int
fake_rtc_write(rtc)
rtc_t *rtc;
{
fake_rtc = *rtc;
return(1);
}
static int
fake_rtc_read(rtc)
rtc_t *rtc;
{
*rtc = fake_rtc;
return(1);
}
static __inline int
yeartoday(year)
int year;
{
return((year % 4) ? 365 : 366);
}
static int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static int timeset = 0;
#define SECPERDAY (24*60*60)
#define SECPERNYEAR (365*SECPERDAY)
#define SECPER4YEARS (4*SECPERNYEAR+SECPERDAY)
#define EPOCHYEAR 1970
/*
* Globally visable functions
*
* These functions are used from other parts of the kernel.
* These functions use the functions defined in the tod_sc
* to actually read and write the rtc.
*
* The first todclock to be attached will be used for handling
* the time of day.
*/
/*
* Write back the time of day to the rtc
*/
void
resettodr()
{
int s;
time_t year, mon, day, hour, min, sec;
rtc_t rtc;
/* Have we set the system time in inittodr() */
if (!timeset)
return;
sec = time.tv_sec;
sec -= rtc_offset * 60;
year = (sec / SECPER4YEARS) * 4;
sec %= SECPER4YEARS;
/* year now hold the number of years rounded down 4 */
while (sec > (yeartoday(EPOCHYEAR+year) * SECPERDAY)) {
sec -= yeartoday(EPOCHYEAR+year)*SECPERDAY;
year++;
}
/* year is now a correct offset from the EPOCHYEAR */
year+=EPOCHYEAR;
mon=0;
if (yeartoday(year) == 366)
month[1]=29;
else
month[1]=28;
while ((sec/SECPERDAY) > month[mon]) {
sec -= month[mon]*SECPERDAY;
mon++;
}
day = sec / SECPERDAY;
sec %= SECPERDAY;
hour = sec / 3600;
sec %= 3600;
min = sec / 60;
sec %= 60;
rtc.rtc_cen = year / 100;
rtc.rtc_year = year % 100;
rtc.rtc_mon = mon+1;
rtc.rtc_day = day+1;
rtc.rtc_hour = hour;
rtc.rtc_min = min;
rtc.rtc_sec = sec;
rtc.rtc_centi =
rtc.rtc_micro = 0;
/*
printf("resettod: %d/%d/%d%d %d:%d:%d\n", rtc.rtc_day,
rtc.rtc_mon, rtc.rtc_cen, rtc.rtc_year, rtc.rtc_hour,
rtc.rtc_min, rtc.rtc_sec);
*/
s = splclock();
/*
if (!todclock_sc)
panic("resettod: No todclock device attached\n");
todclock_sc->sc_rtc_write(&rtc);
*/
fake_rtc_write(&rtc);
(void)splx(s);
}
/*
* Initialise the time of day register, based on the time base which is, e.g.
* from a filesystem.
*/
void
inittodr(base)
time_t base;
{
time_t n;
int i, days = 0;
int s;
int year;
rtc_t rtc;
/*
* We ignore the suggested time for now and go for the RTC
* clock time stored in the CMOS RAM.
*/
/*
if (!todclock_sc)
panic("resettod: No todclock device attached\n");
*/
s = splclock();
/*
if (todclock_sc->sc_rtc_read(&rtc) == 0) {
(void)splx(s);
return;
}
*/
(void)fake_rtc_read(&rtc);
(void)splx(s);
n = rtc.rtc_sec + 60 * rtc.rtc_min + 3600 * rtc.rtc_hour;
n += (rtc.rtc_day - 1) * 3600 * 24;
year = (rtc.rtc_year + rtc.rtc_cen * 100) - 1900;
if (yeartoday(year) == 366)
month[1] = 29;
for (i = rtc.rtc_mon - 2; i >= 0; i--)
days += month[i];
month[1] = 28;
for (i = 70; i < year; i++)
days += yeartoday(i);
n += days * 3600 * 24;
n += rtc_offset * 60;
time.tv_sec = n;
time.tv_usec = 0;
/* timeset is used to ensure the time is valid before a resettodr() */
timeset = 1;
/* If the base was 0 then keep quiet */
if (base) {
printf("inittodr: %02d:%02d:%02d.%02d%02d %02d/%02d/%02d%02d\n",
rtc.rtc_hour, rtc.rtc_min, rtc.rtc_sec, rtc.rtc_centi,
rtc.rtc_micro, rtc.rtc_day, rtc.rtc_mon, rtc.rtc_cen,
rtc.rtc_year);
if (n > base + 60) {
days = (n - base) / SECPERDAY;
printf("Clock has gained %d day%c %ld hours %ld minutes %ld secs\n",
days, ((days == 1) ? 0 : 's'), ((n - base) / 3600) % 24,
((n - base) / 60) % 60, (n - base) % 60);
}
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ofwgencfg_machdep.c,v 1.2 1998/05/01 21:18:44 cgd Exp $ */
/* $NetBSD: ofwgencfg_machdep.c,v 1.3 1998/05/22 17:43:11 cgd Exp $ */
/*
* Copyright 1997
@ -53,6 +53,7 @@
#include <sys/mount.h>
#include <sys/vnode.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
#include <sys/syscallargs.h>
@ -108,7 +109,9 @@ extern pv_addr_t kernelstack;
extern u_int data_abort_handler_address;
extern u_int prefetch_abort_handler_address;
extern u_int undefined_handler_address;
#ifdef PMAP_DEBUG
extern int pmap_debug_level;
#endif
extern int bufpages;
@ -118,7 +121,9 @@ extern int bufpages;
extern void data_abort_handler __P((trapframe_t *frame));
extern void prefetch_abort_handler __P((trapframe_t *frame));
extern void undefinedinstruction_bounce __P((trapframe_t *frame));
#ifdef PMAP_DEBUG
extern void pmap_debug __P((int level));
#endif
#ifdef DDB
extern void db_machine_init __P((void));
#endif
@ -153,7 +158,7 @@ int ofw_handleticks = 0; /* set to TRUE by cpu_initclocks */
*/
void
boot(howto, bootstr)
cpu_reboot(howto, bootstr)
int howto;
char *bootstr;
{
@ -256,8 +261,14 @@ initarm(ofw_handle)
#ifdef DDB
printf("ddb: ");
db_machine_init();
ddb_init();
{
struct exec *kernexec = (struct exec *)KERNEL_BASE;
extern int end;
extern char *esym;
ddb_init(kernexec->a_syms, &end, esym);
printf("ddb_init: a_syms = 0x%lx, end = 0x%lx, esym = 0x%lx\n", kernexec->a_syms, &end, esym);
}
if (boothowto & RB_KDB)
Debugger();
#endif
@ -352,12 +363,14 @@ process_kernel_args(void)
if (strstr(args, "kdb"))
boothowto |= RB_KDB;
#ifdef PMAP_DEBUG
ptr = strstr(args, "pmapdebug=");
if (ptr) {
pmap_debug_level = (int)strtoul(ptr + 10, NULL, 10);
pmap_debug(pmap_debug_level);
debug_flags |= 0x01;
}
#endif
ptr = strstr(args, "nbuf=");
if (ptr)