1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
/**
** Proll (PROM replacement)
** Copyright 1999 Pete Zaitcev
** This code is licensed under GNU General Public License.
**/
#include <stdarg.h>
// #include <asm/contregs.h>
#include <asi.h>
#include "pgtsrmmu.h"
#include "iommu.h" /* Typical SBus IOMMU for sun4m */
#include "phys_jj.h"
#include "vconsole.h"
#include "version.h"
#include <general.h> /* __P() */
#include <net.h> /* init_net() */
#include <romlib.h> /* we are a provider for part of this. */
#include <netpriv.h> /* myipaddr */
#include <arpa.h>
#include <system.h> /* our own prototypes */
void *init_openprom_qemu(int bankc, struct bank *bankv, unsigned hiphybas, const char *cmdline, char boot_device, int nographic);
int vcon_zs_init(struct vconterm *t, unsigned int a0);
int vcon_zs_write(struct vconterm *t, char *data, int leng);
static void init_idprom(void);
struct vconterm dp0;
struct mem cmem; /* Current memory, virtual */
struct mem cio; /* Current I/O space */
struct phym pmem; /* Current phys. mem. */
struct iommu ciommu; /* Our IOMMU on sun4m */
static struct {
const char id[16];
unsigned int version;
char pad1[0x1c]; // Pad to 0x30
unsigned int ram_size;
char boot_device;
unsigned int load_addr, kernel_size;
unsigned int cmdline, cmdline_len;
char pad2[0x0c]; // Pad to 0x54
unsigned short width, height, depth;
} *hw_idprom;
int ignore_fault, fault_ignored;
void *printk_fn;
unsigned int q_height, q_width;
/*
*/
void prolmain()
{
static char fname[14];
static struct banks bb;
unsigned int hiphybas;
const void *romvec;
unsigned int ram_size;
char nographic;
nographic = ldb_bypass(PHYS_JJ_EEPROM + 0x2F);
if (!nographic) {
q_width = ldh_bypass(PHYS_JJ_EEPROM + 0x54);
q_height = ldh_bypass(PHYS_JJ_EEPROM + 0x56);
vcon_init(&dp0, PHYS_JJ_TCX_FB);
printk_fn = vcon_write;
}
else {
vcon_zs_init(&dp0, 0x71100004);
printk_fn = vcon_zs_write;
}
printk("PROLL %s QEMU\n", PROLL_VERSION_STRING);
ram_size = ld_bypass(PHYS_JJ_EEPROM + 0x30);
printk("%d MB total\n", ram_size/(1024*1024));
bb.nbanks = 1;
bb.bankv[0].start = 0;
bb.bankv[0].length = ram_size;
hiphybas = ram_size - PROLSIZE;
mem_init(&cmem, (char *) &_end, (char *)(PROLBASE+PROLSIZE));
makepages(&pmem, hiphybas);
init_mmu_swift((unsigned int)pmem.pctp - PROLBASE + hiphybas);
mem_init(&cio, (char *)(PROLBASE+PROLSIZE),
(char *)(PROLBASE+PROLSIZE+IOMAPSIZE));
iommu_init(&ciommu, hiphybas);
/*
*/
init_idprom();
printk("NVRAM: id %s version %d\n", hw_idprom->id, hw_idprom->version);
if (!nographic)
printk("Prom console: TCX %dx%d\n", q_width, q_height);
else
printk("Prom console: serial\n");
sched_init();
le_probe();
init_net();
printk("Boot device: %c\n", hw_idprom->boot_device);
if (hw_idprom->boot_device == 'n') {
if (bootp() != 0) fatal();
/*
* boot_rec.bp_file cannot be used because system PROM
* uses it to locate ourselves. If we load from boot_rec.bp_file,
* we will loop reloading PROLL over and over again.
* Thus we use traditional PROLL scheme HEXIPADDR.PROL (single L).
*/
xtoa(myipaddr, fname, 8);
fname[9] = '.';
fname[10] = 'P';
fname[11] = 'R';
fname[12] = 'O';
fname[13] = 'L';
fname[14] = 0;
if (load(boot_rec.bp_siaddr, fname) != 0) fatal();
}
romvec = init_openprom_qemu(bb.nbanks, bb.bankv, hiphybas,
(void *)hw_idprom->cmdline, hw_idprom->boot_device, nographic);
printk("Memory used: virt 0x%x:0x%x[%dK] iomap 0x%x:0x%x\n",
PROLBASE, (int)cmem.curp, ((unsigned) cmem.curp - PROLBASE)/1024,
(int)cio.start, (int)cio.curp);
{
void (*entry)(const void *, int, int, int, int) = (void *) hw_idprom->load_addr;
printk("Kernel loaded at 0x%x, size %dK, command line = '%s'\n",
*entry, hw_idprom->kernel_size/1024, hw_idprom->cmdline);
entry(romvec, 0, 0, 0, 0);
}
mem_fini(&cmem);
vcon_fini(&dp0);
}
/*
* dvma_alloc over iommu_alloc.
*/
void *dvma_alloc(int size, unsigned int *pphys)
{
return iommu_alloc(&ciommu, size, pphys);
}
/*
*/
void udelay(unsigned long usecs)
{
// Qemu hardware is perfect and does not need any delays!
}
static void init_idprom()
{
void *va_prom;
if ((va_prom = map_io(PHYS_JJ_EEPROM, PHYS_JJ_EEPROM_SIZE)) == NULL) {
printk("init_idprom: cannot map eeprom\n");
fatal();
}
bcopy(va_prom + PHYS_JJ_IDPROM_OFF, idprom, IDPROM_SIZE);
/*
* hw_idprom is not used anywhere.
* It's just as we hate to leave hanging pointers (I/O page here).
*/
hw_idprom = va_prom;
}
|