Revision 6d82d04a pc-bios/proll.patch

b/pc-bios/proll.patch
1
diff -ruN proll_18.orig/Makefile proll-patch8/Makefile
1
diff -ruN proll_18.orig/Makefile proll-patch10/Makefile
2 2
--- proll_18.orig/Makefile	2002-09-13 14:16:59.000000000 +0000
3
+++ proll-patch8/Makefile	2004-11-13 15:50:49.000000000 +0000
3
+++ proll-patch10/Makefile	2004-11-13 15:50:49.000000000 +0000
4 4
@@ -4,6 +4,7 @@
5 5
 	make -C krups-ser    all
6 6
 	make -C espresso     all
......
14 14
 	make -C espresso     clean
15 15
 	make -C espresso-ser clean
16 16
+	make -C qemu clean
17
diff -ruN proll_18.orig/qemu/Makefile proll-patch8/qemu/Makefile
17
diff -ruN proll_18.orig/qemu/Makefile proll-patch10/qemu/Makefile
18 18
--- proll_18.orig/qemu/Makefile	1970-01-01 00:00:00.000000000 +0000
19
+++ proll-patch8/qemu/Makefile	2005-03-02 16:41:50.000000000 +0000
20
@@ -0,0 +1,122 @@
19
+++ proll-patch10/qemu/Makefile	2005-04-12 14:42:23.000000000 +0000
20
@@ -0,0 +1,123 @@
21 21
+#
22 22
+# proll:
23 23
+# qemu/Makefile - make PROLL for QEMU
24
+# $Id: proll.patch,v 1.4 2005-04-06 20:45:26 bellard Exp $
24
+# $Id: proll.patch,v 1.5 2005-04-26 21:02:48 bellard Exp $
25 25
+#
26 26
+# Copyright 1999 Pete Zaitcev
27 27
+# This is Free Software is licensed under terms of GNU General Public License.
......
47 47
+# want to shift it to form a PGD entry. A relocatable label will not work.
48 48
+# Linux kernel expects us to be at LINUX_OPPROM_BEGVM <asm-sparc/openprom.h>.
49 49
+PROLBASE =   0xffd00000
50
+PROLRODATA = 0xffd07000
51
+PROLDATA =   0xffd09000
50
+PROLRODATA = 0xffd08000
51
+PROLDATA =   0xffd0b000
52 52
+PROLSIZE = 240*1024
53 53
+
54 54
+# Linux
......
68 68
+OBJS = head.o wuf.o wof.o main.o $(CONSOLE) \
69 69
+ printf.o le.o system_qemu.o iommu.o \
70 70
+ arp.o netinit.o bootp.o packet.o tftp.o udp.o sched_4m.o openprom.o \
71
+ vconsole.o hconsole.o rconsole.o vcons_zs.o
71
+ vconsole.o hconsole.o rconsole.o vcons_zs.o esp.o
72 72
+
73 73
+all:           $(ALL)
74 74
+
......
106 106
+	$(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
107 107
+le.o:		$(SRC)/le.c $(SRC)/dma.h $(SRC)/system.h $(SRC)/netpriv.h $(SRC)/romlib.h $(SRC)/general.h $(SRC)/net.h $(SRC)/phys_jj.h
108 108
+	$(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
109
+
109
+esp.o:		$(SRC)/esp.c $(SRC)/dma.h $(SRC)/system.h $(SRC)/romlib.h $(SRC)/general.h $(SRC)/phys_jj.h
110
+	$(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
110 111
+arp.o:		$(SRC)/arp.c $(SRC)/general.h $(SRC)/net.h $(SRC)/romlib.h $(SRC)/netpriv.h $(SRC)/arp.h
111 112
+	$(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
112 113
+netinit.o:	$(SRC)/netinit.c $(SRC)/general.h $(SRC)/net.h $(SRC)/romlib.h $(SRC)/netpriv.h $(SRC)/arp.h $(SRC)/ip.h $(SRC)/udp.h
......
140 141
+
141 142
+proll.aout:	$(PROLLEXE)
142 143
+	$(ELFTOAOUT) -o proll.aout $(PROLLEXE)
143
diff -ruN proll_18.orig/qemu/head.S proll-patch8/qemu/head.S
144
diff -ruN proll_18.orig/qemu/head.S proll-patch10/qemu/head.S
144 145
--- proll_18.orig/qemu/head.S	1970-01-01 00:00:00.000000000 +0000
145
+++ proll-patch8/qemu/head.S	2005-03-02 15:30:47.000000000 +0000
146
+++ proll-patch10/qemu/head.S	2005-03-02 15:30:47.000000000 +0000
146 147
@@ -0,0 +1,539 @@
147 148
+/**
148 149
+ ** Standalone startup code for Linux PROM emulator.
......
150 151
+ ** This code is licensed under GNU General Public License.
151 152
+ **/
152 153
+/*
153
+ * $Id: proll.patch,v 1.4 2005-04-06 20:45:26 bellard Exp $
154
+ * $Id: proll.patch,v 1.5 2005-04-26 21:02:48 bellard Exp $
154 155
+ */
155 156
+
156 157
+#include <psr.h>
......
683 684
+C_LABEL(ldb_bypass):
684 685
+	retl
685 686
+	 lduba [%o0] ASI_M_BYPASS, %o0
686
diff -ruN proll_18.orig/qemu/main.c proll-patch8/qemu/main.c
687
diff -ruN proll_18.orig/qemu/main.c proll-patch10/qemu/main.c
687 688
--- proll_18.orig/qemu/main.c	1970-01-01 00:00:00.000000000 +0000
688
+++ proll-patch8/qemu/main.c	2005-04-03 11:58:46.000000000 +0000
689
@@ -0,0 +1,173 @@
689
+++ proll-patch10/qemu/main.c	2005-04-16 18:03:23.000000000 +0000
690
@@ -0,0 +1,185 @@
690 691
+/**
691 692
+ ** Proll (PROM replacement)
692 693
+ ** Copyright 1999 Pete Zaitcev
......
711 712
+void *init_openprom_qemu(int bankc, struct bank *bankv, unsigned hiphybas, const char *cmdline, char boot_device, int nographic);
712 713
+int vcon_zs_init(struct vconterm *t, unsigned int a0);
713 714
+int vcon_zs_write(struct vconterm *t, char *data, int leng);
714
+
715
+int vcon_zs_getch(struct vconterm *t);
716
+void esp_probe();
717
+int esp_boot(int unit);
715 718
+static void init_idprom(void);
716 719
+
717 720
+struct vconterm dp0;
......
733 736
+} *hw_idprom;
734 737
+
735 738
+int ignore_fault, fault_ignored;
736
+void *printk_fn;
739
+void *printk_fn, *getch_fn;
737 740
+unsigned int q_height, q_width;
738 741
+
739 742
+/*
......
745 748
+	unsigned int hiphybas;
746 749
+	const void *romvec;
747 750
+	unsigned int ram_size;
748
+	char nographic;
751
+	char nographic, bootdev;
749 752
+
750 753
+	nographic = ldb_bypass(PHYS_JJ_EEPROM + 0x2F);
751 754
+	if (!nographic) {
......
753 756
+	    q_height = ldh_bypass(PHYS_JJ_EEPROM + 0x56);
754 757
+	    vcon_init(&dp0, PHYS_JJ_TCX_FB);
755 758
+	    printk_fn = vcon_write;
759
+	    getch_fn = vcon_getch;
756 760
+	}
757 761
+	else {
758 762
+	    vcon_zs_init(&dp0, 0x71100004);
759 763
+	    printk_fn = vcon_zs_write;
764
+	    getch_fn = vcon_zs_getch;
760 765
+	}
761 766
+
762 767
+
......
790 795
+	sched_init();
791 796
+	le_probe();
792 797
+	init_net();
798
+	esp_probe();
793 799
+
794
+	printk("Boot device: %c\n", hw_idprom->boot_device);
795
+	if (hw_idprom->boot_device == 'n') {
800
+	bootdev = hw_idprom->boot_device;
801
+	printk("Boot device: %c\n", bootdev);
802
+	if (hw_idprom->kernel_size > 0) {
803
+	    printk("Kernel already loaded\n");
804
+	} else if (bootdev == 'n') {
796 805
+	    if (bootp() != 0) fatal();
797 806
+	    /*
798 807
+	     * boot_rec.bp_file cannot be used because system PROM
......
809 818
+	    fname[14] = 0;
810 819
+	    
811 820
+	    if (load(boot_rec.bp_siaddr, fname) != 0) fatal();
821
+	} else if (bootdev == 'c') {
822
+	    if (esp_boot(0) != 0) fatal();
823
+	} else if (bootdev == 'd') {
824
+	    if (esp_boot(2) != 0) fatal();
812 825
+	}
813 826
+
814 827
+	romvec = init_openprom_qemu(bb.nbanks, bb.bankv, hiphybas,
......
860 873
+	hw_idprom = va_prom; 
861 874
+}
862 875
+
863
diff -ruN proll_18.orig/qemu/openprom.c proll-patch8/qemu/openprom.c
876
diff -ruN proll_18.orig/qemu/openprom.c proll-patch10/qemu/openprom.c
864 877
--- proll_18.orig/qemu/openprom.c	1970-01-01 00:00:00.000000000 +0000
865
+++ proll-patch8/qemu/openprom.c	2005-04-06 16:53:31.000000000 +0000
866
@@ -0,0 +1,665 @@
878
+++ proll-patch10/qemu/openprom.c	2005-04-16 17:30:19.000000000 +0000
879
@@ -0,0 +1,741 @@
867 880
+/*
868 881
+ * PROM interface support
869 882
+ * Copyright 1996 The Australian National University.
......
882 895
+
883 896
+//#define DEBUG_OBP
884 897
+
898
+#define PAGE_SIZE 4096
899
+
885 900
+struct property {
886 901
+	const char *name;
887 902
+	const char *value;
......
1275 1290
+static int obp_devopen(char *str);
1276 1291
+static int obp_devclose(int dev_desc);
1277 1292
+static int obp_rdblkdev(int dev_desc, int num_blks, int blk_st, char *buf);
1293
+static char *obp_dumb_mmap(char *va, int which_io, unsigned int pa, unsigned int size);
1294
+static void obp_dumb_munmap(char *va, unsigned int size);
1278 1295
+
1279 1296
+static void doublewalk(unsigned ptab1, unsigned va)
1280 1297
+{
......
1353 1370
+	romvec0.pv_nbgetchar = obp_nbgetchar;
1354 1371
+	romvec0.pv_nbputchar = obp_nbputchar;
1355 1372
+	romvec0.pv_reboot = obp_reboot;
1373
+	romvec0.pv_printf = (void (*)(const char *fmt, ...))printk;
1356 1374
+	romvec0.pv_abort = obp_abort;
1357 1375
+	romvec0.pv_halt = obp_halt;
1358 1376
+	romvec0.pv_synchook = &synch_hook;
1359 1377
+	romvec0.pv_v0bootargs = &obp_argp;
1378
+	romvec0.pv_v2devops.v2_dumb_mmap = obp_dumb_mmap;
1379
+	romvec0.pv_v2devops.v2_dumb_munmap = obp_dumb_munmap;
1380
+	obp_arg.boot_dev_ctrl = 0;
1381
+	obp_arg.boot_dev_unit = '0';
1360 1382
+	switch(boot_device) {
1361 1383
+	default:
1362 1384
+	case 'a':
1363 1385
+	    obp_arg.argv[0] = "fd()";
1386
+	    obp_arg.boot_dev[0] = 'f';
1387
+	    obp_arg.boot_dev[1] = 'd';
1364 1388
+	    break;
1389
+	case 'd':
1390
+	    obp_arg.boot_dev_unit = '2';
1391
+	    // Fall through
1365 1392
+	case 'c':
1366 1393
+	    obp_arg.argv[0] = "sd()";
1394
+	    obp_arg.boot_dev[0] = 's';
1395
+	    obp_arg.boot_dev[1] = 'd';
1367 1396
+	    break;
1368 1397
+	case 'n':
1369 1398
+	    obp_arg.argv[0] = "le()";
1399
+	    obp_arg.boot_dev[0] = 'l';
1400
+	    obp_arg.boot_dev[1] = 'e';
1370 1401
+	    break;
1371 1402
+	}
1372 1403
+	obp_arg.argv[1] = cmdline;
......
1483 1514
+	return (const char *)-1;
1484 1515
+}
1485 1516
+
1517
+extern int (*getch_fn)(struct vconterm *v);
1518
+
1486 1519
+static int obp_nbgetchar(void) {
1487 1520
+	extern struct vconterm dp0;
1488
+	return vcon_getch(&dp0);
1521
+	return getch_fn(&dp0);
1489 1522
+}
1490 1523
+
1491 1524
+static int obp_nbputchar(int ch) {
......
1507 1540
+	printk("halt, freezing\n");
1508 1541
+	for (;;) {}
1509 1542
+}
1510
+
1543
+#define isnum(c) ((c >= '0') && (c < '9'))
1544
+#define ctoi(c) (c - '0')
1511 1545
+static int obp_devopen(char *str) {
1512 1546
+#ifdef DEBUG_OBP
1513
+        printk("open %s\n", str);
1547
+        printk("obp_devopen(%s)\n", str);
1514 1548
+#endif
1549
+	if (str[0] == 's' && str[1] == 'd' && str[4] == ',') {
1550
+	    unsigned int target;
1551
+
1552
+	    if (str[5] < 7)
1553
+		target = str[5];
1554
+	    else if (isnum(str[6]) && isnum(str[5])) {
1555
+		target = (ctoi(str[5]) * 10 + ctoi(str[6])) & 7;
1556
+	    }
1557
+	    else {
1558
+		target = ctoi(str[5]) & 7;
1559
+	    }
1560
+	    return 's' + target;
1561
+	}
1515 1562
+	return 0;
1516 1563
+}
1517 1564
+
1518 1565
+static int obp_devclose(int dev_desc) {
1519 1566
+#ifdef DEBUG_OBP
1520
+        printk("close %d\n", dev_desc);
1567
+        printk("obp_devclose %d\n", dev_desc);
1521 1568
+#endif
1522 1569
+	return 0;
1523 1570
+}
1524 1571
+
1525
+static int obp_rdblkdev(int dev_desc, int num_blks, int blk_st, char *buf) {
1572
+extern void *esp_read(int unit, int offset, short len);
1573
+
1574
+static int obp_rdblkdev(int dev_desc, int num_blks, int offset, char *buf)
1575
+{
1576
+    unsigned int i;
1577
+    void *src;
1578
+
1526 1579
+#ifdef DEBUG_OBP
1527
+    printk("rdblkdev: fd %d, num_blks %d, blk_st %d, buf 0x%x\n", dev_desc, num_blks, blk_st, buf);
1580
+    printk("obp_rdblkdev: fd %d, num_blks %d, offset %d, buf 0x%x\n", dev_desc, num_blks, offset, buf);
1528 1581
+#endif
1529
+    //buf[8] = 'L';
1530
+    return num_blks;
1582
+    if (dev_desc >= 's' && dev_desc < 'v') {
1583
+	for(i = 0; i < num_blks; i++) {
1584
+	    src = esp_read(dev_desc - 's', offset + i, 1);
1585
+	    memcpy(&buf[i << 9], src, 512);
1586
+	}
1587
+	return num_blks;
1588
+    }
1589
+    return -1;
1531 1590
+}
1532
diff -ruN proll_18.orig/qemu/system_qemu.c proll-patch8/qemu/system_qemu.c
1591
+
1592
+static char *obp_dumb_mmap(char *va, int which_io, unsigned int pa, unsigned int size)
1593
+{
1594
+	unsigned int npages;
1595
+	unsigned int off;
1596
+	unsigned int mva;
1597
+
1598
+#ifdef DEBUG_OBP
1599
+	printk("obp_dumb_mmap: virta %x, which_io %d, paddr %x, sz %d\n", va, which_io, pa, size);
1600
+#endif
1601
+	off = pa & (PAGE_SIZE-1);
1602
+	npages = (off + size + (PAGE_SIZE-1)) / PAGE_SIZE;
1603
+	pa &= ~(PAGE_SIZE-1);
1604
+
1605
+	mva = (unsigned int) va;
1606
+	while (npages-- != 0) {
1607
+		map_page(pmem.pl1, mva, pa, 1, pmem.pbas);
1608
+		mva += PAGE_SIZE;
1609
+		pa += PAGE_SIZE;
1610
+	}
1611
+	return va;
1612
+}
1613
+
1614
+static void obp_dumb_munmap(char *va, unsigned int size)
1615
+{
1616
+#ifdef DEBUG_OBP
1617
+	printk("obp_dumb_munmap: virta %x, sz %d\n", va, size);
1618
+#endif
1619
+    
1620
+}
1621
diff -ruN proll_18.orig/qemu/system_qemu.c proll-patch10/qemu/system_qemu.c
1533 1622
--- proll_18.orig/qemu/system_qemu.c	1970-01-01 00:00:00.000000000 +0000
1534
+++ proll-patch8/qemu/system_qemu.c	2005-03-02 16:10:20.000000000 +0000
1535
@@ -0,0 +1,416 @@
1623
+++ proll-patch10/qemu/system_qemu.c	2005-04-16 06:16:20.000000000 +0000
1624
@@ -0,0 +1,430 @@
1536 1625
+/**
1537 1626
+ ** Proll (PROM replacement)
1538 1627
+ ** system.c: shared miscallenea.
......
1859 1948
+{
1860 1949
+	char *p;
1861 1950
+
1862
+	if ((p = mem_alloc(t, size, align)) != 0) bzero(p, size);
1951
+	if ((p = mem_alloc(t, size, align)) != 0) memset(p, 0, size);
1863 1952
+	return p;
1864 1953
+}
1865 1954
+
1866 1955
+/*
1867 1956
+ * Library functions
1868 1957
+ */
1869
+void bzero(void *s, int len) {
1870
+	while (len--) *((char *)s)++ = 0;
1958
+void *memset(void *s, int c, size_t len)
1959
+{
1960
+	void *p = s;
1961
+
1962
+	while (len--) {
1963
+		*(char *)s = c;
1964
+		s++;
1965
+	}
1966
+	return p;
1871 1967
+}
1872 1968
+
1873 1969
+void bcopy(const void *f, void *t, int len) {
1874
+	while (len--) *((char *)t)++ = *((char *)f)++;
1970
+	while (len--) {
1971
+		*(char *)t = *(char *)f;
1972
+		f++;
1973
+		t++;
1974
+	}
1875 1975
+}
1876 1976
+
1877 1977
+/* Comparison is 7-bit */
......
1881 1981
+	char ch;
1882 1982
+
1883 1983
+	while (len--) {
1884
+		ch = *((char *)s1)++;
1885
+		if ((i = ch - *((char *)s2)++) != 0)
1984
+		ch = *(char *)s1;
1985
+		i = ch - *(char *)s2;
1986
+		s1++;
1987
+		s2++;
1988
+		if (i != 0)
1886 1989
+			return i;
1887 1990
+		if (ch == 0)
1888 1991
+			return 0;
......
1949 2052
+	n = (n>>24 & 0xFF) | (n>>8 & 0xFF00) | ((n&0xFF00) << 8) | (n<<24);
1950 2053
+	st_bypass(ptr, n);
1951 2054
+};
1952
diff -ruN proll_18.orig/src/arp.c proll-patch8/src/arp.c
2055
diff -ruN proll_18.orig/src/arp.c proll-patch10/src/arp.c
1953 2056
--- proll_18.orig/src/arp.c	2001-12-24 05:12:31.000000000 +0000
1954
+++ proll-patch8/src/arp.c	2004-11-13 15:50:49.000000000 +0000
2057
+++ proll-patch10/src/arp.c	2004-11-13 15:50:49.000000000 +0000
1955 2058
@@ -45,7 +45,7 @@
1956 2059
 #endif
1957 2060
 static struct arp_cache arp_list[ARPNUM];	/* ARP address cache	*/
......
1986 2089
+  def_gw = IP_ANY;
1987 2090
   return(TRUE);
1988 2091
 }
1989
diff -ruN proll_18.orig/src/arp.h proll-patch8/src/arp.h
2092
diff -ruN proll_18.orig/src/arp.h proll-patch10/src/arp.h
1990 2093
--- proll_18.orig/src/arp.h	1999-03-18 03:39:43.000000000 +0000
1991
+++ proll-patch8/src/arp.h	2004-11-13 15:50:49.000000000 +0000
2094
+++ proll-patch10/src/arp.h	2004-11-13 15:50:49.000000000 +0000
1992 2095
@@ -104,7 +104,7 @@
1993 2096
 extern int init_arp __P((void));
1994 2097
 
......
1998 2101
 
1999 2102
 /* Add a new antry to the ARP cache */
2000 2103
 extern void addcache __P((unsigned char *ha, t_ipaddr ip));
2001
diff -ruN proll_18.orig/src/hconsole.c proll-patch8/src/hconsole.c
2104
diff -ruN proll_18.orig/src/esp.c proll-patch10/src/esp.c
2105
--- proll_18.orig/src/esp.c	1970-01-01 00:00:00.000000000 +0000
2106
+++ proll-patch10/src/esp.c	2005-04-16 06:24:23.000000000 +0000
2107
@@ -0,0 +1,252 @@
2108
+#include <system.h>		/* == <asm/system.h> */
2109
+#include <general.h>		/* __P for netpriv.h */
2110
+#include <dma.h>		/* dmaga */
2111
+#include <romlib.h>
2112
+
2113
+#define PHYS_JJ_ESPDMA  0x78400000      /* ESP DMA controller */
2114
+#define PHYS_JJ_ESP     0x78800000      /* ESP SCSI */
2115
+#define PHYS_JJ_ESP_IRQ    4
2116
+#define BUFSIZE         4096
2117
+/*
2118
+ * XXX Crude
2119
+ */
2120
+struct esp_dma {
2121
+	struct sparc_dma_registers *regs;
2122
+	enum dvma_rev revision;
2123
+};
2124
+
2125
+struct esp_regs {
2126
+    unsigned int regs[16];
2127
+};
2128
+
2129
+struct esp_private {
2130
+	int active;			/* initialized */
2131
+	int inst;			/* iface number */
2132
+
2133
+	volatile struct esp_regs *ll;
2134
+	__u32 buffer_dvma;
2135
+	unsigned int irq;		/* device IRQ number    */
2136
+        int interrupt;
2137
+
2138
+	struct esp_dma *espdma;         /* If set this points to espdma    */
2139
+
2140
+        unsigned char *buffer;
2141
+};
2142
+
2143
+static void esp_interrupt(void *dev_id)
2144
+{
2145
+	struct esp_private *lp = (struct esp_private *)dev_id;
2146
+
2147
+	lp->interrupt = 1;
2148
+	/* Acknowledge all the interrupt sources ASAP */
2149
+
2150
+	lp->interrupt = 0;
2151
+}
2152
+
2153
+static int esp_open (void *dev)
2154
+{
2155
+	struct esp_private *lp = (struct esp_private *)dev;
2156
+	int status = 0;
2157
+
2158
+	if (request_irq(lp->irq, &esp_interrupt, (void *)dev)) {
2159
+		printk ("Esp: Can't get irq %d\n", lp->irq);
2160
+		return -1;
2161
+	}
2162
+
2163
+	/* On the 4m, setup the espdma to provide the upper bits for buffers */
2164
+	if (lp->espdma)
2165
+		lp->espdma->regs->dma_test = ((__u32) lp->buffer_dvma) & 0xff000000;
2166
+
2167
+	return status;
2168
+}
2169
+
2170
+static int esp_close (void *dev)
2171
+{
2172
+	struct esp_private *lp = (struct esp_private *)dev;
2173
+
2174
+	free_irq (lp->irq, (void *) dev);
2175
+	return 0;
2176
+}
2177
+
2178
+static int 
2179
+esp_init(struct esp_private *esp, struct esp_dma *espdma, int irq)
2180
+{
2181
+	volatile struct esp_regs *ll;
2182
+
2183
+	/* Get the IO region */
2184
+	ll = map_io(PHYS_JJ_ESP, sizeof (struct esp_regs));
2185
+	if (ll == 0) return -1;
2186
+
2187
+	esp->buffer = dvma_alloc(BUFSIZE, &esp->buffer_dvma);
2188
+	esp->ll = ll;
2189
+	esp->espdma = espdma;
2190
+	esp->irq = irq;
2191
+
2192
+	// Chip reset
2193
+	stb_bypass((int)ll + 3*2, 2);
2194
+	return 0;
2195
+}
2196
+
2197
+static int espdma_init(struct esp_dma *espdma)
2198
+{
2199
+	void *p;
2200
+
2201
+	/* Hardcode everything for MrCoffee. */
2202
+	if ((p = map_io(PHYS_JJ_ESPDMA, 0x10)) == 0) {
2203
+		printk("espdma_init: cannot map registers\n");
2204
+		return -1;
2205
+	}
2206
+	espdma->regs = p;
2207
+
2208
+	printk("dma1: ");
2209
+
2210
+	switch((espdma->regs->cond_reg)&DMA_DEVICE_ID) {
2211
+	case DMA_VERS0:
2212
+		espdma->revision=dvmarev0;
2213
+		printk("Revision 0 ");
2214
+		break;
2215
+	case DMA_ESCV1:
2216
+		espdma->revision=dvmaesc1;
2217
+		printk("ESC Revision 1 ");
2218
+		break;
2219
+	case DMA_VERS1:
2220
+		espdma->revision=dvmarev1;
2221
+		printk("Revision 1 ");
2222
+		break;
2223
+	case DMA_VERS2:
2224
+		espdma->revision=dvmarev2;
2225
+		printk("Revision 2 ");
2226
+		break;
2227
+	case DMA_VERHME:
2228
+		espdma->revision=dvmahme;
2229
+		printk("HME DVMA gate array ");
2230
+		break;
2231
+	case DMA_VERSPLUS:
2232
+		espdma->revision=dvmarevplus;
2233
+		printk("Revision 1 PLUS ");
2234
+		break;
2235
+	default:
2236
+		printk("unknown dma version %x",
2237
+		       (espdma->regs->cond_reg)&DMA_DEVICE_ID);
2238
+		/* espdma->allocated = 1; */
2239
+		break;
2240
+	}
2241
+	printk("\n");
2242
+	return 0;
2243
+}
2244
+
2245
+static struct esp_dma espdma0;
2246
+static struct esp_private esp;
2247
+/*
2248
+ * Find all the esp cards on the system and initialize them
2249
+ */
2250
+void esp_probe ()
2251
+{
2252
+	if (espdma_init(&espdma0) != 0) {
2253
+		return;
2254
+	}
2255
+
2256
+	if (esp_init(&esp, &espdma0, PHYS_JJ_ESP_IRQ) != 0) {
2257
+		printk("esp_probe: esp0 init failed\n");
2258
+		return;
2259
+	}
2260
+	return;
2261
+}
2262
+
2263
+void *esp_read(int unit, int offset, short len)
2264
+{
2265
+	// Set SCSI target
2266
+	stb_bypass(PHYS_JJ_ESP + 4*4, unit & 7);
2267
+	// Set DMA address
2268
+	st_bypass(PHYS_JJ_ESPDMA + 4, esp.buffer_dvma);
2269
+	// Set DMA length
2270
+	stb_bypass(PHYS_JJ_ESP + 0*4, 10);
2271
+	stb_bypass(PHYS_JJ_ESP + 1*4, 0);
2272
+	// Set DMA direction
2273
+	st_bypass(PHYS_JJ_ESPDMA + 0, 0x000);
2274
+	// Setup command = Read(10)
2275
+	esp.buffer[0] = 0x80;
2276
+	esp.buffer[1] = 0x28;
2277
+	esp.buffer[2] = 0x00;
2278
+	esp.buffer[3] = (offset >> 24) & 0xff;
2279
+	esp.buffer[4] = (offset >> 16) & 0xff;
2280
+	esp.buffer[5] = (offset >> 8) & 0xff;
2281
+	esp.buffer[6] = offset & 0xff;
2282
+	esp.buffer[7] = 0x00;
2283
+	esp.buffer[8] = (len >> 8) & 0xff;
2284
+	esp.buffer[9] = len & 0xff;
2285
+	// Set ATN, issue command
2286
+	stb_bypass(PHYS_JJ_ESP + 3*4, 0x42);
2287
+
2288
+	// Set DMA length = 512 * read length
2289
+	stb_bypass(PHYS_JJ_ESP + 0*4, 0);
2290
+	stb_bypass(PHYS_JJ_ESP + 1*4, (len << 1) & 0xff);
2291
+	// Set DMA direction
2292
+	st_bypass(PHYS_JJ_ESPDMA + 0, 0x100);
2293
+	// Transfer
2294
+	stb_bypass(PHYS_JJ_ESP + 3*4, 0x10);
2295
+	return esp.buffer;
2296
+}
2297
+
2298
+// Sparc boot sequence can be found in SILO docs,
2299
+// first-isofs/README.SILO_ISOFS
2300
+int esp_boot(int unit)
2301
+{
2302
+        struct sun_disklabel {
2303
+                unsigned char info[128];   /* Informative text string */
2304
+                unsigned char spare0[14];
2305
+                struct sun_info {
2306
+                        unsigned char spare1;
2307
+                        unsigned char id;
2308
+                        unsigned char spare2;
2309
+                        unsigned char flags;
2310
+                } infos[8];
2311
+                unsigned char spare[246];  /* Boot information etc. */
2312
+                short rspeed;     /* Disk rotational speed */
2313
+                short pcylcount;  /* Physical cylinder count */
2314
+                short sparecyl;   /* extra sects per cylinder */
2315
+                unsigned char spare2[4];   /* More magic... */
2316
+                short ilfact;     /* Interleave factor */
2317
+                short ncyl;       /* Data cylinder count */
2318
+                short nacyl;      /* Alt. cylinder count */
2319
+                short ntrks;      /* Tracks per cylinder */
2320
+                short nsect;      /* Sectors per track */
2321
+                unsigned char spare3[4];   /* Even more magic... */
2322
+                struct sun_partition {
2323
+                        int start_cylinder;
2324
+                        int num_sectors;
2325
+                } partitions[8];
2326
+                short magic;      /* Magic number */
2327
+                short csum;       /* Label xor'd checksum */
2328
+        } *label;
2329
+	unsigned int i, offset;
2330
+	void *src, *dst;
2331
+
2332
+	printk("Loading partition table from target %d:\n", unit);
2333
+	// Chip reset
2334
+	stb_bypass(PHYS_JJ_ESP + 3*4, 2);
2335
+
2336
+	esp_open(&esp);
2337
+
2338
+	label = esp_read(unit, 0, 1);
2339
+	printk("CHS: %d/%d/%d, partitions:\n", label->ncyl, label->ntrks, label->nsect);
2340
+	for (i = 0; i < 8; i++) {
2341
+	    printk("%c: %d + %d\n", 'a' + i, label->partitions[i].start_cylinder,
2342
+		   label->partitions[i].num_sectors);
2343
+	}
2344
+	offset = label->partitions[4].start_cylinder * label->ntrks * label->nsect + 1;
2345
+	printk("booting sd(0,%d,0):d (offset %d)\n", unit, offset);
2346
+	// Skip a.out header (0x20)
2347
+	dst = (void *)0x4000;
2348
+	src = esp_read(unit, offset, 1);
2349
+	src = (void *)((unsigned int) src + 0x20);
2350
+	memcpy(dst, src, 512 - 0x20);
2351
+	dst = (void *)0x4000 + 512 - 0x20;
2352
+	for (i = 1; i < 7680/512; i++) {
2353
+	    src = esp_read(unit, offset + i, 1);
2354
+	    memcpy(dst, src, 512);
2355
+	    dst += 512;
2356
+	}
2357
+	esp_close(&esp);
2358
+	return 0;
2359
+}
2360
diff -ruN proll_18.orig/src/hconsole.c proll-patch10/src/hconsole.c
2002 2361
--- proll_18.orig/src/hconsole.c	2002-07-23 05:52:48.000000000 +0000
2003
+++ proll-patch8/src/hconsole.c	2005-03-02 17:03:09.000000000 +0000
2362
+++ proll-patch10/src/hconsole.c	2005-03-02 17:03:09.000000000 +0000
2004 2363
@@ -29,6 +29,10 @@
2005 2364
        struct raster r_master;	/* For a case of resize, whole fb */
2006 2365
        struct raster r_0;	/* malloc() erzatz */
......
2024 2383
 	t->r_ = r;
2025 2384
 	t->r0_ = q;
2026 2385
 	t->f_ = &f_master;
2027
diff -ruN proll_18.orig/src/lat7_2.bm proll-patch8/src/lat7_2.bm
2386
diff -ruN proll_18.orig/src/hme.c proll-patch10/src/hme.c
2387
--- proll_18.orig/src/hme.c	2002-07-23 05:52:52.000000000 +0000
2388
+++ proll-patch10/src/hme.c	2005-04-16 06:16:20.000000000 +0000
2389
@@ -655,10 +655,10 @@
2390
 				    unsigned int flags,
2391
 				    unsigned int addr)
2392
 {
2393
-	__asm__ __volatile__("
2394
-	stwa	%3, [%0] %2
2395
-	stwa	%4, [%1] %2
2396
-"	: /* no outputs */
2397
+	__asm__ __volatile__(
2398
+	"stwa	%3, [%0] %2\n\t"
2399
+	"stwa	%4, [%1] %2\n\t"
2400
+	: /* no outputs */
2401
 	: "r" (&rp->rx_addr), "r" (&rp->rx_flags),
2402
 	  "i" (ASI_PL), "r" (addr), "r" (flags));
2403
 }
2404
@@ -667,10 +667,10 @@
2405
 				    unsigned int flags,
2406
 				    unsigned int addr)
2407
 {
2408
-	__asm__ __volatile__("
2409
-	stwa	%3, [%0] %2
2410
-	stwa	%4, [%1] %2
2411
-"	: /* no outputs */
2412
+	__asm__ __volatile__(
2413
+	"stwa	%3, [%0] %2\n\t"
2414
+	"stwa	%4, [%1] %2\n\t"
2415
+	: /* no outputs */
2416
 	: "r" (&tp->tx_addr), "r" (&tp->tx_flags),
2417
 	  "i" (ASI_PL), "r" (addr), "r" (flags));
2418
 }
2419
@@ -2404,7 +2404,7 @@
2420
 		TXD(("[%d]", elem));
2421
 		this = &txbase[elem];
2422
 #ifdef  __sparc_v9__
2423
-		__asm__ __volatile__("lduwa [%1] %2, %0"
2424
+		__asm__ __volatile__("lduwa [%1] %2, %0\n\t"
2425
 				     : "=r" (flags)
2426
 				     : "r" (&this->tx_flags), "i" (ASI_PL));
2427
 #else
2428
@@ -2447,7 +2447,7 @@
2429
 	RXD(("RX<"));
2430
 	this = &rxbase[elem];
2431
 #ifdef  __sparc_v9__
2432
-	__asm__ __volatile__("lduwa [%1] %2, %0"
2433
+	__asm__ __volatile__("lduwa [%1] %2, %0\n\t"
2434
 			     : "=r" (flags)
2435
 			     : "r" (&this->rx_flags), "i" (ASI_PL));
2436
 #else
2437
@@ -2530,7 +2530,7 @@
2438
 		elem = NEXT_RX(elem);
2439
 		this = &rxbase[elem];
2440
 #ifdef __sparc_v9__ 
2441
-		__asm__ __volatile__("lduwa [%1] %2, %0"
2442
+		__asm__ __volatile__("lduwa [%1] %2, %0\n\t"
2443
 				     : "=r" (flags)
2444
 				     : "r" (&this->rx_flags), "i" (ASI_PL));
2445
 #else
2446
diff -ruN proll_18.orig/src/lat7_2.bm proll-patch10/src/lat7_2.bm
2028 2447
--- proll_18.orig/src/lat7_2.bm	1999-02-27 05:48:54.000000000 +0000
2029
+++ proll-patch8/src/lat7_2.bm	2004-11-13 15:50:49.000000000 +0000
2448
+++ proll-patch10/src/lat7_2.bm	2004-11-13 15:50:49.000000000 +0000
2030 2449
@@ -1,6 +1,6 @@
2031 2450
 #define lat7_2_width 128
2032 2451
 #define lat7_2_height 88
......
2035 2454
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2036 2455
    0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x12, 0x1e, 0x0c, 0x02, 0x70, 0x18,
2037 2456
    0x22, 0x22, 0x18, 0x00, 0x00, 0x18, 0x18, 0xff, 0x18, 0x00, 0x12, 0x02,
2038
diff -ruN proll_18.orig/src/lat7_2_swapped.bm proll-patch8/src/lat7_2_swapped.bm
2457
diff -ruN proll_18.orig/src/lat7_2_swapped.bm proll-patch10/src/lat7_2_swapped.bm
2039 2458
--- proll_18.orig/src/lat7_2_swapped.bm	1970-01-01 00:00:00.000000000 +0000
2040
+++ proll-patch8/src/lat7_2_swapped.bm	2004-11-13 15:50:49.000000000 +0000
2459
+++ proll-patch10/src/lat7_2_swapped.bm	2004-11-13 15:50:49.000000000 +0000
2041 2460
@@ -0,0 +1,121 @@
2042 2461
+#define lat7_2_width 128
2043 2462
+#define lat7_2_height 88
......
2160 2579
+   0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0x00, 0x00, 0x00, 
2161 2580
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x42, 0x00, 0x00, 0x00, 0x00, 
2162 2581
+   0x00, 0x00, 0x00, 0x00};
2163
diff -ruN proll_18.orig/src/le.c proll-patch8/src/le.c
2582
diff -ruN proll_18.orig/src/le.c proll-patch10/src/le.c
2164 2583
--- proll_18.orig/src/le.c	2002-07-23 05:52:49.000000000 +0000
2165
+++ proll-patch8/src/le.c	2004-11-13 15:50:49.000000000 +0000
2584
+++ proll-patch10/src/le.c	2005-04-16 06:16:20.000000000 +0000
2166 2585
@@ -185,8 +185,6 @@
2167 2586
 	unsigned short rap;			/* register address port */
2168 2587
 };
......
2172 2591
 /* The Lance uses 24 bit addresses */
2173 2592
 /* On the Sun4c the DVMA will provide the remaining bytes for us */
2174 2593
 /* On the Sun4m we have to instruct the ledma to provide them    */
2175
diff -ruN proll_18.orig/src/netinit.c proll-patch8/src/netinit.c
2594
@@ -771,7 +769,7 @@
2595
 	/* Clear the slack of the packet, do I need this? */
2596
 	/* For a firewall its a good idea - AC */
2597
 	if (len != skblen)
2598
-		bzero((char *) &ib->tx_buf [entry][skblen], len - skblen);
2599
+		memset((char *) &ib->tx_buf [entry][skblen], 0, len - skblen);
2600
     
2601
 	/* Now, give the packet to the lance */
2602
 	ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN);
2603
diff -ruN proll_18.orig/src/netinit.c proll-patch10/src/netinit.c
2176 2604
--- proll_18.orig/src/netinit.c	2002-09-13 21:53:33.000000000 +0000
2177
+++ proll-patch8/src/netinit.c	2004-11-13 15:50:49.000000000 +0000
2605
+++ proll-patch10/src/netinit.c	2004-11-13 15:50:49.000000000 +0000
2178 2606
@@ -49,13 +49,20 @@
2179 2607
 unsigned char     myhwaddr[ETH_ALEN];		/* my own hardware addr	*/
2180 2608
          t_ipaddr myipaddr;			/* my own IP address	*/
......
2218 2646
 	fatal();
2219 2647
   }
2220 2648
 }
2221
diff -ruN proll_18.orig/src/netpriv.h proll-patch8/src/netpriv.h
2649
diff -ruN proll_18.orig/src/netpriv.h proll-patch10/src/netpriv.h
2222 2650
--- proll_18.orig/src/netpriv.h	1999-04-27 05:39:37.000000000 +0000
2223
+++ proll-patch8/src/netpriv.h	2004-11-13 15:50:49.000000000 +0000
2651
+++ proll-patch10/src/netpriv.h	2004-11-13 15:50:49.000000000 +0000
2224 2652
@@ -130,10 +130,9 @@
2225 2653
  *
2226 2654
  */
......
2242 2670
 
2243 2671
 /* Empty read buffer */
2244 2672
 extern void empty_buf __P((void));
2245
diff -ruN proll_18.orig/src/openprom.h proll-patch8/src/openprom.h
2673
diff -ruN proll_18.orig/src/openprom.h proll-patch10/src/openprom.h
2246 2674
--- proll_18.orig/src/openprom.h	2002-07-14 02:26:30.000000000 +0000
2247
+++ proll-patch8/src/openprom.h	2004-11-13 15:50:49.000000000 +0000
2675
+++ proll-patch10/src/openprom.h	2004-11-13 15:50:49.000000000 +0000
2248 2676
@@ -54,20 +54,20 @@
2249 2677
 };
2250 2678
 
......
2306 2734
 };
2307 2735
 
2308 2736
 /* More fun PROM structures for device probing. */
2309
diff -ruN proll_18.orig/src/packet.c proll-patch8/src/packet.c
2737
diff -ruN proll_18.orig/src/packet.c proll-patch10/src/packet.c
2310 2738
--- proll_18.orig/src/packet.c	2000-02-11 04:56:45.000000000 +0000
2311
+++ proll-patch8/src/packet.c	2004-11-13 15:50:49.000000000 +0000
2739
+++ proll-patch10/src/packet.c	2004-11-13 15:50:49.000000000 +0000
2312 2740
@@ -41,7 +41,7 @@
2313 2741
 	int aligner;
2314 2742
 } wbuf;
......
2336 2764
 {
2337 2765
 	struct sk_buff *skb;
2338 2766
 	unsigned char *s;
2339
diff -ruN proll_18.orig/src/printf.c proll-patch8/src/printf.c
2767
diff -ruN proll_18.orig/src/printf.c proll-patch10/src/printf.c
2340 2768
--- proll_18.orig/src/printf.c	1999-03-19 07:03:59.000000000 +0000
2341
+++ proll-patch8/src/printf.c	2004-11-13 15:50:49.000000000 +0000
2769
+++ proll-patch10/src/printf.c	2004-11-13 15:50:49.000000000 +0000
2342 2770
@@ -19,7 +19,7 @@
2343 2771
 static void printn(struct prf_fp *, unsigned long, unsigned int);
2344 2772
 static void putchar(char, struct prf_fp *);
......
2366 2794
                         	putchar(c,filog);
2367 2795
        		} else if (c == 'l' || c == 'O') {
2368 2796
         	        printn(filog, (long)va_arg(adx,long), c=='l'?10:8);
2369
diff -ruN proll_18.orig/src/rconsole.c proll-patch8/src/rconsole.c
2797
diff -ruN proll_18.orig/src/rconsole.c proll-patch10/src/rconsole.c
2370 2798
--- proll_18.orig/src/rconsole.c	1999-01-16 07:16:55.000000000 +0000
2371
+++ proll-patch8/src/rconsole.c	2004-11-13 15:50:49.000000000 +0000
2799
+++ proll-patch10/src/rconsole.c	2005-04-16 06:16:20.000000000 +0000
2372 2800
@@ -28,12 +28,18 @@
2373 2801
  * move to California. Only plain lat7 survived. 
2374 2802
  * I recreated lat7-1 changes in lat7-2.  --zaitcev
......
2388 2816
 
2389 2817
 #if 1
2390 2818
 /*
2819
@@ -46,18 +52,18 @@
2820
 #endif
2821
 
2822
 static __inline__ void stfb_w(void *ptr, unsigned int data) {
2823
-	__asm__ __volatile__ ("sta %0, [%1] %2" : :
2824
+	__asm__ __volatile__ ("sta %0, [%1] %2\n\t" : :
2825
 				"r" (data), "r" (ptr), "i" (ASI_M_BYPASS));
2826
 }
2827
 
2828
 static __inline__ void stfb_b(void *ptr, unsigned int data) {
2829
-	__asm__ __volatile__ ("stba %0, [%1] %2" : :
2830
+	__asm__ __volatile__ ("stba %0, [%1] %2\n\t" : :
2831
 				"r" (data), "r" (ptr), "i" (ASI_M_BYPASS));
2832
 }
2833
 
2834
 static __inline__ unsigned int ldfb_w(void *ptr) {
2835
 	unsigned int data;
2836
-	__asm__ __volatile__ ("lda [%1] %2, %0" :
2837
+	__asm__ __volatile__ ("lda [%1] %2, %0\n\t" :
2838
 				"=r" (data) :
2839
 				"r" (ptr), "i" (ASI_M_BYPASS));
2840
 	return data;
2841
@@ -65,7 +71,7 @@
2842
 
2843
 static __inline__ unsigned int ldfb_b(void *ptr) {
2844
 	unsigned int data;
2845
-	__asm__ __volatile__ ("lduba [%1] %2, %0" :
2846
+	__asm__ __volatile__ ("lduba [%1] %2, %0\n\t" :
2847
 				"=r" (data) :
2848
 				"r" (ptr), "i" (ASI_M_BYPASS));
2849
 	return data;
2391 2850
@@ -94,6 +100,7 @@
2392 2851
 
2393 2852
 #endif
......
2423 2882
   p->nchars_ = LAT7_NCHARS;
2424 2883
   p->width_ = LAT7_WIDTH;
2425 2884
   p->height_ = LAT7_HEIGHT;
2426
diff -ruN proll_18.orig/src/rconsole.h proll-patch8/src/rconsole.h
2885
diff -ruN proll_18.orig/src/rconsole.h proll-patch10/src/rconsole.h
2427 2886
--- proll_18.orig/src/rconsole.h	1999-01-16 05:00:59.000000000 +0000
2428
+++ proll-patch8/src/rconsole.h	2004-11-13 15:50:49.000000000 +0000
2887
+++ proll-patch10/src/rconsole.h	2004-11-13 15:50:49.000000000 +0000
2429 2888
@@ -13,10 +13,10 @@
2430 2889
  */
2431 2890
 
......
2439 2898
   int nchars_;                 /* 128 for ASCII ...  65536 for Unicode   */
2440 2899
   int width_;                  /* [Pixels]. Maximum size is 16.          */
2441 2900
   int height_;                 /* [Pixels == scan lines].                */
2442
diff -ruN proll_18.orig/src/romlib.h proll-patch8/src/romlib.h
2901
diff -ruN proll_18.orig/src/romlib.h proll-patch10/src/romlib.h
2443 2902
--- proll_18.orig/src/romlib.h	1999-04-20 04:26:45.000000000 +0000
2444
+++ proll-patch8/src/romlib.h	2004-11-13 15:50:49.000000000 +0000
2445
@@ -73,12 +73,12 @@
2903
+++ proll-patch10/src/romlib.h	2005-04-16 20:32:49.000000000 +0000
2904
@@ -72,13 +72,13 @@
2905
  */
2446 2906
 #define memcpy(dst, src, len)	bcopy(src, dst, len)
2447 2907
 #define memcmp(x1, x2, len)	bcmp(x1, x2, len)
2448
 #define memset(p, len, zero)	bzero(p, len)
2908
-#define memset(p, len, zero)	bzero(p, len)
2449 2909
-extern void bcopy(void *b1, void *b2, int length);
2450 2910
-extern int  bcmp(void *b1, void *b2, int length);
2911
-extern void bzero(void *b, int c);
2451 2912
+extern void bcopy(const void *b1, void *b2, int length);
2452 2913
+extern int  bcmp(const void *b1, const void *b2, int length);
2453
 extern void bzero(void *b, int c);
2914
+typedef unsigned int size_t;
2915
+extern void *memset(void *p, int c, size_t len);
2454 2916
 /* gcc complains about "conflicting types for builtin function strlen". */
2455 2917
 #define strlen(s)		ssize(s)
2456 2918
-extern int ssize(char *s);
......
2458 2920
 
2459 2921
 
2460 2922
 /*
2461
diff -ruN proll_18.orig/src/sched_4m.c proll-patch8/src/sched_4m.c
2923
diff -ruN proll_18.orig/src/sched_4m.c proll-patch10/src/sched_4m.c
2462 2924
--- proll_18.orig/src/sched_4m.c	1999-04-27 05:48:51.000000000 +0000
2463
+++ proll-patch8/src/sched_4m.c	2004-11-13 15:50:49.000000000 +0000
2925
+++ proll-patch10/src/sched_4m.c	2004-11-13 15:50:49.000000000 +0000
2464 2926
@@ -108,7 +108,7 @@
2465 2927
 static int set_bolt;			/* Tick counter limit */
2466 2928
 static struct handsc hndv[16];
......
2470 2932
 	0,	0,	0,	0,	0,	0, SUN4M_INT_ETHERNET,	0,
2471 2933
 	0,	0,	0,	0,	0,	0,	0,	0,
2472 2934
 };
2473
diff -ruN proll_18.orig/src/swap.c proll-patch8/src/swap.c
2935
diff -ruN proll_18.orig/src/swap.c proll-patch10/src/swap.c
2474 2936
--- proll_18.orig/src/swap.c	1970-01-01 00:00:00.000000000 +0000
2475
+++ proll-patch8/src/swap.c	2004-11-13 15:50:49.000000000 +0000
2937
+++ proll-patch10/src/swap.c	2004-11-13 15:50:49.000000000 +0000
2476 2938
@@ -0,0 +1,21 @@
2477 2939
+// Convert the lat7 font so that no conversion is needed at runtime.
2478 2940
+#define ORIG
......
2495 2957
+    }
2496 2958
+    printf("\n");
2497 2959
+}
2498
diff -ruN proll_18.orig/src/system.c proll-patch8/src/system.c
2960
diff -ruN proll_18.orig/src/system.c proll-patch10/src/system.c
2499 2961
--- proll_18.orig/src/system.c	2002-07-23 05:52:49.000000000 +0000
2500
+++ proll-patch8/src/system.c	2004-11-13 15:50:49.000000000 +0000
2962
+++ proll-patch10/src/system.c	2005-04-16 06:16:20.000000000 +0000
2501 2963
@@ -298,8 +298,8 @@
2502 2964
 	}
2503 2965
 
......
2509 2971
 		map_page(l1, va, pa, 0, highbase);
2510 2972
 		pa += PAGE_SIZE;
2511 2973
 	}
2512
@@ -518,12 +518,12 @@
2513
 	while (len--) *((char *)s)++ = 0;
2974
@@ -507,30 +507,44 @@
2975
 {
2976
 	char *p;
2977
 
2978
-	if ((p = mem_alloc(t, size, align)) != 0) bzero(p, size);
2979
+	if ((p = mem_alloc(t, size, align)) != 0) memset(p, 0, size);
2980
 	return p;
2981
 }
2982
 
2983
 /*
2984
  * Library functions
2985
  */
2986
-void bzero(void *s, int len) {
2987
-	while (len--) *((char *)s)++ = 0;
2988
+void *memset(void *s, int c, size_t len)
2989
+{
2990
+	void *p = s;
2991
+
2992
+	while (len--) {
2993
+		*(char *)s = c;
2994
+		s++;
2995
+	}
2996
+	return p;
2514 2997
 }
2515 2998
 
2516 2999
-void bcopy(void *f, void *t, int len) {
3000
-	while (len--) *((char *)t)++ = *((char *)f)++;
2517 3001
+void bcopy(const void *f, void *t, int len) {
2518
 	while (len--) *((char *)t)++ = *((char *)f)++;
3002
+	while (len--) {
3003
+		*(char *)t = *(char *)f;
3004
+		f++;
3005
+		t++;
3006
+	}
2519 3007
 }
2520 3008
 
2521 3009
 /* Comparison is 7-bit */
......
2524 3012
 {
2525 3013
 	int i;
2526 3014
 	char ch;
2527
@@ -538,8 +538,8 @@
3015
 
3016
 	while (len--) {
3017
-		ch = *((char *)s1)++;
3018
-		if ((i = ch - *((char *)s2)++) != 0)
3019
+		ch = *(char *)s1;
3020
+		i = ch - *(char *)s2;
3021
+		s1++;
3022
+		s2++;
3023
+		if (i != 0)
3024
 			return i;
3025
 		if (ch == 0)
3026
 			return 0;
3027
@@ -538,8 +552,8 @@
2528 3028
 	return 0;
2529 3029
 }
2530 3030
 
......
2535 3035
 	for (p = s; *p != 0; p++) { }
2536 3036
 	return p - s;
2537 3037
 }
2538
@@ -560,14 +560,6 @@
3038
@@ -560,14 +574,6 @@
2539 3039
 	va_end(x1);
2540 3040
 }
2541 3041
 
......
2550 3050
 void fatal()
2551 3051
 {
2552 3052
 	printk("fatal.");
2553
diff -ruN proll_18.orig/src/system.h proll-patch8/src/system.h
3053
diff -ruN proll_18.orig/src/system.h proll-patch10/src/system.h
2554 3054
--- proll_18.orig/src/system.h	2002-09-13 21:53:32.000000000 +0000
2555
+++ proll-patch8/src/system.h	2004-11-13 15:50:49.000000000 +0000
3055
+++ proll-patch10/src/system.h	2005-04-16 06:16:20.000000000 +0000
2556 3056
@@ -16,7 +16,7 @@
2557 3057
 #define IOMAPSIZE (1*1024*1024) /* 1 Meg maximum: we do not map framebuffer. */
2558 3058
 #define NCTX_SWIFT  0x100
......
2562 3062
 
2563 3063
 #ifndef __ASSEMBLY__
2564 3064
 struct bank {
2565
diff -ruN proll_18.orig/src/udp.c proll-patch8/src/udp.c
3065
@@ -164,10 +164,10 @@
3066
 
3067
 extern __inline__ void setipl(unsigned long __orig_psr)
3068
 {
3069
-	__asm__ __volatile__("
3070
-		wr	%0, 0x0, %%psr
3071
-		nop; nop; nop
3072
-"		: /* no outputs */
3073
+	__asm__ __volatile__(
3074
+		"wr	%0, 0x0, %%psr\n\t"
3075
+		"nop; nop; nop\n\t"
3076
+		: /* no outputs */
3077
 		: "r" (__orig_psr)
3078
 		: "memory", "cc");
3079
 }
3080
@@ -176,13 +176,13 @@
3081
 {
3082
 	unsigned long tmp;
3083
 
3084
-	__asm__ __volatile__("
3085
-		rd	%%psr, %0
3086
-		nop; nop; nop;		/* Sun4m + Cypress + SMP bug */
3087
-		or	%0, %1, %0
3088
-		wr	%0, 0x0, %%psr
3089
-		nop; nop; nop
3090
-"		: "=r" (tmp)
3091
+	__asm__ __volatile__(
3092
+		"rd	%%psr, %0\n\t"
3093
+		"nop; nop; nop;\n\t"	/* Sun4m + Cypress + SMP bug */
3094
+		"or	%0, %1, %0\n\t"
3095
+		"wr	%0, 0x0, %%psr\n\t"
3096
+		"nop; nop; nop\n\t"
3097
+		: "=r" (tmp)
3098
 		: "i" (PSR_PIL)
3099
 		: "memory");
3100
 }
3101
@@ -191,13 +191,13 @@
3102
 {
3103
 	unsigned long tmp;
3104
 
3105
-	__asm__ __volatile__("
3106
-		rd	%%psr, %0	
3107
-		nop; nop; nop;		/* Sun4m + Cypress + SMP bug */
3108
-		andn	%0, %1, %0
3109
-		wr	%0, 0x0, %%psr
3110
-		nop; nop; nop
3111
-"		: "=r" (tmp)
3112
+	__asm__ __volatile__(
3113
+		"rd	%%psr, %0\n\t"
3114
+		"nop; nop; nop;\n\t"	/* Sun4m + Cypress + SMP bug */
3115
+		"andn	%0, %1, %0\n\t"
3116
+		"wr	%0, 0x0, %%psr\n\t"
3117
+		"nop; nop; nop\n\t"
3118
+		: "=r" (tmp)
3119
 		: "i" (PSR_PIL)
3120
 		: "memory");
3121
 }
3122
@@ -214,18 +214,18 @@
3123
 {
3124
 	unsigned long retval;
3125
 
3126
-	__asm__ __volatile__("
3127
-		rd	%%psr, %0
3128
-		nop; nop; nop;		/* Sun4m + Cypress + SMP bug */
3129
-		and	%0, %2, %%g1
3130
-		and	%1, %2, %%g2
3131
-		xorcc	%%g1, %%g2, %%g0
3132
-		be	1f
3133
-		 nop
3134
-		wr	%0, %2, %%psr
3135
-		nop; nop; nop;
3136
-1:
3137
-"		: "=r" (retval)
3138
+	__asm__ __volatile__(
3139
+		"rd	%%psr, %0\n\t"
3140
+		"nop; nop; nop;\n\t"	/* Sun4m + Cypress + SMP bug */
3141
+		"and	%0, %2, %%g1\n\t"
3142
+		"and	%1, %2, %%g2\n\t"
3143
+		"xorcc	%%g1, %%g2, %%g0\n\t"
3144
+		"be	1f\n\t"
3145
+		"nop\n\t"
3146
+		"wr	%0, %2, %%psr\n\t"
3147
+		"nop; nop; nop;\n\t"
3148
+		"1:\n\t"
3149
+		: "=r" (retval)
3150
 		: "r" (__new_psr), "i" (PSR_PIL)
3151
 		: "g1", "g2", "memory", "cc");
3152
 
3153
@@ -236,13 +236,13 @@
3154
 {
3155
 	unsigned long retval;
3156
 
3157
-	__asm__ __volatile__("
3158
-		rd	%%psr, %0
3159
-		nop; nop; nop;		/* Sun4m + Cypress + SMP bug */
3160
-		or	%0, %1, %%g1
3161
-		wr	%%g1, 0x0, %%psr
3162
-		nop; nop; nop
3163
-"		: "=r" (retval)
3164
+	__asm__ __volatile__(
3165
+		"rd	%%psr, %0\n\t"
3166
+		"nop; nop; nop;\n\t"	/* Sun4m + Cypress + SMP bug */
3167
+		"or	%0, %1, %%g1\n\t"
3168
+		"wr	%%g1, 0x0, %%psr\n\t"
3169
+		"nop; nop; nop\n\t"
3170
+		: "=r" (retval)
3171
 		: "i" (PSR_PIL)
3172
 		: "g1", "memory");
3173
 
3174
diff -ruN proll_18.orig/src/udp.c proll-patch10/src/udp.c
2566 3175
--- proll_18.orig/src/udp.c	2001-12-24 05:12:53.000000000 +0000
2567
+++ proll-patch8/src/udp.c	2004-11-13 15:50:49.000000000 +0000
3176
+++ proll-patch10/src/udp.c	2004-11-13 15:50:49.000000000 +0000
2568 3177
@@ -81,7 +81,7 @@
2569 3178
 int      source;
2570 3179
 int      dest;
......
2584 3193
   /* Register IP packet type and set write buffer pointer */
2585 3194
   if ((writebuf = reg_type(htons(ETH_P_IP), ip_recv)) == NULL)
2586 3195
 	return(FALSE);
2587
diff -ruN proll_18.orig/src/vcons_zs.c proll-patch8/src/vcons_zs.c
3196
diff -ruN proll_18.orig/src/vcons_zs.c proll-patch10/src/vcons_zs.c
2588 3197
--- proll_18.orig/src/vcons_zs.c	1970-01-01 00:00:00.000000000 +0000
2589
+++ proll-patch8/src/vcons_zs.c	2005-03-20 10:25:39.000000000 +0000
3198
+++ proll-patch10/src/vcons_zs.c	2005-04-10 07:01:03.000000000 +0000
2590 3199
@@ -0,0 +1,68 @@
2591 3200
+/**
2592 3201
+ ** Console over 'zs' (Zilog serial port)
......
2648 3257
+	unsigned zs_ptr = (unsigned) t->impl;
2649 3258
+
2650 3259
+	while ((ldb_bypass(zs_ptr) & 1) != 1) { }
2651
+	return ldb_bypass(zs_ptr + ZS_DATA);
3260
+	return ldb_bypass(zs_ptr + ZS_DATA) & 0xff;
2652 3261
+}
2653 3262
+
2654 3263
+void vcon_zs_fini(struct vconterm *t)
......
2656 3265
+	/* violent crash in the end */
2657 3266
+	;
2658 3267
+}
2659
diff -ruN proll_18.orig/src/vconsole.c proll-patch8/src/vconsole.c
3268
diff -ruN proll_18.orig/src/vconsole.c proll-patch10/src/vconsole.c
2660 3269
--- proll_18.orig/src/vconsole.c	1999-11-08 03:10:28.000000000 +0000
2661
+++ proll-patch8/src/vconsole.c	2005-03-02 14:29:05.000000000 +0000
2662
@@ -13,6 +13,10 @@
3270
+++ proll-patch10/src/vconsole.c	2005-04-17 19:23:21.000000000 +0000
3271
@@ -7,12 +7,17 @@
3272
 #include "vconsole.h"
3273
 
3274
 #include "hconsole.h"
3275
+#include <system.h>
3276
 
3277
 static void vcon_i_cursfeed(struct vconterm *t);
3278
 static void vcon_i_backflush(struct vconterm *t);
2663 3279
 
2664 3280
 struct hconsole hcons0;
2665 3281
 
......
2670 3286
 int vcon_init(struct vconterm *t, unsigned int a0)
2671 3287
 {
2672 3288
 	struct hconsole *hconp;
2673
@@ -25,11 +29,49 @@
3289
@@ -25,11 +30,49 @@
2674 3290
 
2675 3291
 	t->vc_x = 0;    t->vc_y = 0;
2676 3292
 	t->backp = 0;    t->backc = 0;
......
2720 3336
 int vcon_write(struct vconterm *t, char *data, int leng)
2721 3337
 {
2722 3338
 	int l = leng;
2723
@@ -40,29 +82,84 @@
3339
@@ -40,29 +83,99 @@
2724 3340
 		if (l <= 0) break;
2725 3341
 		c = *data++;    --l;
2726 3342
 
......
2741 3357
+			case 'M':
2742 3358
+				hcon_scroll(hconp, 0, hcon_qydim(hconp), SM_UP, 1);
2743 3359
+				break;
3360
+			default:
3361
+				printk("Unhandled escape code '%c'\n", c);
3362
+				break;
2744 3363
+			}
2745 3364
 			break;
2746 3365
-		case 0x0D:		/* Return */
......
2768 3387
+				if (t->vc_par[1]) t->vc_par[1]--;
2769 3388
+				gotoxay(t, t->vc_par[1], t->vc_par[0]);
2770 3389
+				break;
3390
+			case 'J':
3391
+				if (t->vc_par[0] == 0) {
3392
+					//erase from cursor to end of display
3393
+					hcon_clear(hconp, t->vc_y, t->vc_x, hconp->ydim_, hconp->xdim_);
3394
+				}
3395
+				break;
2771 3396
+			case 'M':
2772 3397
+				hcon_scroll(hconp, 0, hcon_qydim(hconp), SM_UP, 1);
2773 3398
+				break;
3399
+			case 'm':
3400
+				break;
3401
+			default:
3402
+				printk("Unhandled escape code '%c', par[%d, %d, %d, %d, %d]\n",
3403
+				   c, t->vc_par[0], t->vc_par[1], t->vc_par[2], t->vc_par[3], t->vc_par[4]);
3404
+				break;
2774 3405
+			}
2775 3406
 			break;
2776 3407
 		default:
......
2823 3454
 			}
2824 3455
 		}
2825 3456
 	}
2826
diff -ruN proll_18.orig/src/vconsole.h proll-patch8/src/vconsole.h
3457
@@ -100,9 +213,62 @@
3458
 	return 0;
3459
 }
3460
 
3461
+static const unsigned char sunkbd_keycode[128] = {
3462
+    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
3463
+    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0,
3464
+    '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 8,
3465
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
3466
+    'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
3467
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3468
+    'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '\\', 13,
3469
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3470
+    'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
3471
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3472
+    ' ',
3473
+};
3474
+
3475
+static const unsigned char sunkbd_keycode_shifted[128] = {
3476
+    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,
3477
+    0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0,
3478
+    '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 0, 8,
3479
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
3480
+    'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}',
3481
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3482
+    'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '|', 13,
3483
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3484
+    'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?',
3485
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3486
+    ' ',
3487
+};
3488
+
3489
+static int shiftstate;
3490
+
3491
 int vcon_getch(struct vconterm *t)
3492
 {
3493
-	return -1;
3494
+        int ch;
3495
+
3496
+	while ((ldb_bypass(0x71000004) & 1) != 1) { }
3497
+	do {
3498
+	    ch = ldb_bypass(0x71000006) & 0xff;
3499
+	    if (ch == 99)
3500
+		shiftstate |= 1;
3501
+	    else if (ch == 110)
3502
+		shiftstate |= 2;
3503
+	    else if (ch == 227)
3504
+		shiftstate &= ~1;
3505
+	    else if (ch == 238)
3506
+		shiftstate &= ~2;
3507
+	    //printk("getch: %d\n", ch);
3508
+	}
3509
+	while ((ch & 0x80) == 0 || ch == 238 || ch == 227); // Wait for key release
3510
+	//printk("getch rel: %d\n", ch);
3511
+	ch &= 0x7f;
3512
+	if (shiftstate)
3513
+	    ch = sunkbd_keycode_shifted[ch];
3514
+	else
3515
+	    ch = sunkbd_keycode[ch];
3516
+	//printk("getch xlate: %d\n", ch);
3517
+	return ch;
3518
 }
3519
 
3520
 void vcon_fini(struct vconterm *t)
3521
diff -ruN proll_18.orig/src/vconsole.h proll-patch10/src/vconsole.h
2827 3522
--- proll_18.orig/src/vconsole.h	1999-11-08 00:58:13.000000000 +0000
2828
+++ proll-patch8/src/vconsole.h	2005-03-02 12:40:12.000000000 +0000
3523
+++ proll-patch10/src/vconsole.h	2005-03-02 12:40:12.000000000 +0000
2829 3524
@@ -6,6 +6,8 @@
2830 3525
 #ifndef VCONSOLE_H
2831 3526
 #define VCONSOLE_H

Also available in: Unified diff