Subject: Re: Ericsson MC16 (HP 360LX) endianness
To: Adam Wysocki via ArcaBit <gophi@arcabit.pl>
From: Christer O. Andersson <christer@a-son.net>
List: port-hpcsh
Date: 07/31/2006 12:11:19
--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Jul 31, 2006 at 11:15:33AM +0200, Adam Wysocki via ArcaBit wrote:
> Yes, I know... I've linked it with -static, shouldn't it be enough?

I doubt it, though I haven't tried. -static takes care of shared
library dependencies, but you still need code that initiates the
cpu and sets things in known states, you need a stack, interrupt
vectors etc.

> > and make sure you have source code with the memory detection 
> > patches Uwe mentioned applied. You can get the patch from me 
> > if Uwe haven't found the time to apply them.
> 
> Sounds promising - can you send me these patches?

You find the patch attached. Without it the system will reboot.
Note that the patch is a bit dated, but hopefully it will still
apply.  Uwe didn't quite like it, I think, so it is possible he
will change it a bit before committing, but this will work in the
mean time.
 
> > If you like, I can provide you with the hpcboot, kernel and miniroot 
> > I use.
> 
> Would be nice :) Thanks in advance.

I can put them somewhere tonight, when I have physical access to
my MC16 and the CF.

-- 
Christer O. Andersson
Odensbacken

--9amGYk9869ThD9tj
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="machdep.c.patch"

--- sys/arch/hpcsh/hpcsh/machdep.c.1.51	2005-12-25 00:24:00.000000000 +0100
+++ sys/arch/hpcsh/hpcsh/machdep.c	2006-01-15 01:07:16.000000000 +0100
@@ -134,6 +134,18 @@
  * 0x0d000000 --- onboard   16MByte (shadow)
  * 0x0e000000 --- onboard   16MByte (shadow)
  * 0x0f000000 --- onboard   16MByte (shadow)
+ *
+ * HP 360LX (Ericsson MC16)
+ *
+ * CS3 (0x0c000000-0x0fffffff
+ * 0x0c000000 --- onboard    8MByte
+ * 0x0c800000 --- unused     8MByte
+ * 0x0d000000 --- onboard    8MByte (shadow)
+ * 0x0d800000 --- unused     8MByte (shadow)
+ * 0x0e000000 --- onboard    8MByte (shadow)
+ * 0x0e800000 --- unused     8MByte (shadow)
+ * 0x0f000000 --- onboard    8MByte (shadow)
+ * 0x0f800000 --- unused     8MByte (shadow)
  */
 
 #define	SH_CS3_START			0x0c000000
@@ -154,6 +166,9 @@
 static int	mem_cluster_init(paddr_t);
 static void	mem_cluster_load(void);
 static void	__find_dram_shadow(paddr_t, paddr_t);
+#ifdef SH3
+static int	__probe_memory(paddr_t);
+#endif
 #ifdef NARLY_MEMORY_PROBE
 static int	__check_dram(paddr_t, paddr_t);
 #endif
@@ -441,9 +456,18 @@
 #ifdef SH3
 	/* SH7709A's CS3 is split to 2 banks. */
 	if (CPU_IS_SH3) {
-		__find_dram_shadow(addr, SH7709_CS3_BANK0_END);
-		__find_dram_shadow(SH7709_CS3_BANK1_START,
-		    SH7709_CS3_BANK1_END);
+		if (platid_match(&platid, &platid_mask_MACH_HP_LX_360)) {
+			__find_dram_shadow(addr, SH7709_CS3_BANK0_END);
+
+			/* Check if any memory present above 8MByte */
+			if (__probe_memory(SH7709_CS3_BANK0_START+0x00800000) != 0) {
+				mem_clusters[1].size = 0x00800000 - mem_clusters[0].size;
+			}
+		} else {
+			__find_dram_shadow(addr, SH7709_CS3_BANK0_END);
+			__find_dram_shadow(SH7709_CS3_BANK1_START,
+			    SH7709_CS3_BANK1_END);
+		}
 	}
 #endif
 #ifdef SH4
@@ -532,6 +556,10 @@
 	    *(volatile int *)(page + 4) != ~x)
 		return; /* no memory in this bank */
 
+        page += PAGE_SIZE;
+	if (mem_cluster_cnt == 1)
+		page += mem_clusters[0].size;
+
  memend_found:
 	KASSERT(mem_cluster_cnt < VM_PHYSSEG_MAX);
 
@@ -545,6 +573,27 @@
 	mem_cluster_cnt++;
 }
 
+#ifdef SH3
+int
+__probe_memory(paddr_t probe_addr)
+{
+	vaddr_t addr;
+	int x;
+
+	addr = SH3_PHYS_TO_P2SEG(probe_addr);
+
+	x = random();
+	*(volatile int *)(addr + 0) = x;
+	*(volatile int *)(addr + 4) = ~x;
+
+	if (*(volatile int *)(addr + 0) != x ||
+	    *(volatile int *)(addr + 4) != ~x)
+		return (1);
+
+	return (0);
+}
+#endif
+
 #ifdef NARLY_MEMORY_PROBE
 int
 __check_dram(paddr_t start, paddr_t end)

--9amGYk9869ThD9tj--