Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 5 commits
  • 8 files changed
  • 0 comments
  • 1 contributor
1  sys/arch/lm32/conf/files.lm32
@@ -3,3 +3,4 @@ include "arch/lm32/conf/majors.lm32"
3 3
 file 	arch/lm32/lm32/pmap.c
4 4
 file 	arch/lm32/lm32/copy.c
5 5
 file    arch/lm32/lm32/lock_stubs.S
  6
+file    arch/lm32/lm32/mmu.c
16  sys/arch/lm32/include/cpu.h
@@ -61,6 +61,22 @@
61 61
 struct intrsource;
62 62
 struct pmap;
63 63
 
  64
+#define lm32_dcache_invalidate() do { \
  65
+					asm volatile("wcsr DCC, r0"); \
  66
+				} while(0);
  67
+
  68
+#define lm32_icache_invalidate() do { \
  69
+					asm volatile("wcsr ICC, r0\n" \
  70
+						     "nop\n" \
  71
+						     "nop\n" \
  72
+						     "nop\n" \
  73
+						     "nop\n"); \
  74
+				} while(0);
  75
+
  76
+
  77
+void lm32_dtlb_invalidate_line(vaddr_t vaddr);
  78
+void lm32_itlb_invalidate_line(vaddr_t vaddr);
  79
+
64 80
 /*
65 81
  * a bunch of this belongs in cpuvar.h; move it later..
66 82
  */
4  sys/arch/lm32/include/vmparam.h
@@ -41,7 +41,7 @@
41 41
 #include <sys/mutex.h>
42 42
 
43 43
 
44  
-#define	PAGE_SHIFT	12
  44
+#define	PAGE_SHIFT	(12)
45 45
 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
46 46
 #define	PAGE_MASK	(PAGE_SIZE - 1)
47 47
 
@@ -104,4 +104,6 @@
104 104
 #define	VM_FREELIST_FIRST16	1
105 105
 #define	VM_FREELIST_DEFAULT	0
106 106
 
  107
+#define lm32_ptob(x)  ((uint32_t)(x) << PGSHIFT)
  108
+
107 109
 #endif /* _LM32_VMPARAM_H_ */
87  sys/arch/lm32/lm32/copy.c
@@ -11,6 +11,8 @@
11 11
 void do_pmap_load(void);
12 12
 int copyout(const void *kaddr, void *uaddr, size_t len);
13 13
 int copyin(const void *uaddr, void *kaddr, size_t len);
  14
+int copyinstr(const void *from, void *to, size_t max_len, size_t *len_copied);
  15
+int copystr(const void *kfaddr, void *kdaddr, size_t maxlen, size_t *done);
14 16
 
15 17
 void do_pmap_load(void)
16 18
 {
@@ -98,3 +100,88 @@ int copyout(const void *kaddr, void *uaddr, size_t len)
98 100
 
99 101
 	return 0;
100 102
 }
  103
+
  104
+int copyinstr(const void *from, void *to, size_t max_len, size_t *len_copied)
  105
+{
  106
+	const char *from_8 = (const char *)from;
  107
+	char *to_8 = (char *)to;
  108
+	int ret = 0;
  109
+	size_t maxlen_temp = max_len;
  110
+
  111
+	if ( curcpu()->ci_want_pmapload )
  112
+		do_pmap_load();
  113
+
  114
+	if ((size_t)from > VM_MAXUSER_ADDRESS) /* to be checked, jump if carry ? */
  115
+	{
  116
+		ret = EFAULT;
  117
+		goto copyinstr_return;
  118
+	}
  119
+
  120
+	if (max_len > VM_MAXUSER_ADDRESS - (size_t)from)
  121
+		max_len = VM_MAXUSER_ADDRESS - (size_t)from;
  122
+
  123
+	maxlen_temp++;
  124
+
  125
+	do
  126
+	{
  127
+		if (--maxlen_temp == 0)
  128
+		{
  129
+			ret = 1;
  130
+			break;
  131
+		}
  132
+		*to_8++ = *from_8;
  133
+	} while (*from_8++ != '\0');
  134
+
  135
+
  136
+	if (ret)
  137
+	{
  138
+		if (VM_MAXUSER_ADDRESS >= (size_t)from_8)
  139
+			ret = EFAULT;
  140
+		else
  141
+			ret = ENAMETOOLONG;
  142
+	}
  143
+	else
  144
+	{
  145
+		maxlen_temp--; 
  146
+		ret = 0;
  147
+	}
  148
+
  149
+copyinstr_return:
  150
+	if (NULL != len_copied)
  151
+		*len_copied = max_len - maxlen_temp;
  152
+
  153
+	return ret;
  154
+}
  155
+
  156
+
  157
+int copystr(const void *kfaddr, void *kdaddr, size_t maxlen, size_t *done)
  158
+{
  159
+	const char *from_8 = kfaddr;
  160
+	char *to_8 = kdaddr;
  161
+	size_t maxlen_temp = maxlen;
  162
+	int ret = 0;
  163
+
  164
+	from_8--;
  165
+	maxlen_temp++;
  166
+
  167
+	do
  168
+	{
  169
+		if (--maxlen_temp == 0)
  170
+		{
  171
+			ret = ENAMETOOLONG;
  172
+			break;
  173
+		}
  174
+		*to_8++ = *from_8;
  175
+	} while (*from_8++ != '\0');
  176
+
  177
+	if (ret == 0)
  178
+	{
  179
+		maxlen_temp--;
  180
+	} else
  181
+		ret = ENAMETOOLONG;
  182
+
  183
+	if (NULL != done)
  184
+		*done = maxlen - maxlen_temp;
  185
+
  186
+	return ret;
  187
+}
18  sys/arch/lm32/lm32/mmu.c
... ...
@@ -0,0 +1,18 @@
  1
+
  2
+/*
  3
+ * COPYRIGHT (C) 2013 Yann Sionneau <yann.sionneau@gmail.com>
  4
+ */
  5
+
  6
+#include <lm32/cpu.h>
  7
+
  8
+void lm32_dtlb_invalidate_line(vaddr_t vaddr)
  9
+{
  10
+	vaddr |= 0x21;
  11
+	asm volatile ("wcsr tlbvaddr, %0" :: "r"(vaddr) : );
  12
+}
  13
+
  14
+void lm32_itlb_invalidate_line(vaddr_t vaddr)
  15
+{
  16
+	vaddr |= 0x20;
  17
+	asm volatile ("wcsr tlbvaddr, %0" :: "r"(vaddr) : );
  18
+}
1  sys/arch/milkymist/conf/files.milkymist
@@ -22,5 +22,6 @@ attach	uart at mainbus
22 22
 file	arch/milkymist/dev/uart.c		uart needs-flag
23 23
 
24 24
 file	arch/milkymist/milkymist/intr.c
  25
+file	arch/milkymist/milkymist/machdep.c
25 26
 
26 27
 include "arch/milkymist/conf/majors.milkymist"
2  sys/arch/milkymist/include/cpu.h
@@ -7,4 +7,6 @@ extern struct cpu_info cpu_info_store;
7 7
 
8 8
 #include <lm32/cpu.h>
9 9
 
  10
+#define CPU_CONSDEV 1
  11
+
10 12
 #endif
80  sys/arch/milkymist/milkymist/machdep.c
@@ -67,11 +67,6 @@
67 67
 #include <sys/cdefs.h>
68 68
 __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.43 2012/06/11 16:27:08 tsutsui Exp $");
69 69
 
70  
-#include "opt_memsize.h"
71  
-#include "scif.h"
72  
-#include "opt_kloader.h"
73  
-#include "opt_modular.h"
74  
-
75 70
 #include <sys/param.h>
76 71
 #include <sys/systm.h>
77 72
 #include <sys/kernel.h>
@@ -83,13 +78,10 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.43 2012/06/11 16:27:08 tsutsui Exp $")
83 78
 #include <sys/module.h>
84 79
 
85 80
 #include <machine/intr.h>
86  
-#include <machine/kloader.h>
87 81
 #include <machine/pcb.h>
88 82
 
89 83
 #include <dev/cons.h>
90 84
 
91  
-#include "ksyms.h"
92  
-
93 85
 /* the following is used externally (sysctl_hw) */
94 86
 char machine[] = MACHINE;
95 87
 char machine_arch[] = MACHINE_ARCH;
@@ -97,9 +89,14 @@ char machine_arch[] = MACHINE_ARCH;
97 89
 
98 90
 /* Our exported CPU info; we can have only one. */
99 91
 struct cpu_info cpu_info_store;
  92
+static struct pcb lwp0pcb;
100 93
 
101 94
 void main(void) __attribute__((__noreturn__));
102 95
 void milkymist_startup(void) __attribute__((__noreturn__));
  96
+void lm32_lwp0_init(void);
  97
+
  98
+#define IOM_RAM_BEGIN (0x40000000)
  99
+#define IOM_RAM_SIZE (0x08000000) /* 128 MB of DDR SDRAM on the Milkymist One */
103 100
 
104 101
 void
105 102
 milkymist_startup(void)
@@ -111,21 +108,21 @@ milkymist_startup(void)
111 108
 	memset(edata, 0, end - edata);
112 109
 
113 110
 	/* Initialize CPU ops. */
114  
-	lm32_cpu_init();
  111
+//	lm32_cpu_init();
115 112
 
116 113
 	/* Console */
117 114
 	consinit();
118 115
 
119 116
 	/* Load memory to UVM */
120 117
 	physmem = atop(IOM_RAM_SIZE);
121  
-	kernend = atop(round_page(end));
  118
+	kernend = atop(round_page((unsigned int)end));
122 119
 	uvm_page_physload(
123 120
 		kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
124 121
 		kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
125 122
 		VM_FREELIST_DEFAULT);
126 123
 
127 124
 	/* Initialize proc0 u-area */
128  
-	lm32_proc0_init();
  125
+	lm32_lwp0_init();
129 126
 
130 127
 	/* Initialize pmap and start to address translation */
131 128
 	pmap_bootstrap();
@@ -140,14 +137,24 @@ milkymist_startup(void)
140 137
 
141 138
 	/* Jump to main */
142 139
 	__asm volatile(
143  
-		"jmp	@%0;"
144  
-		"mov	%1, sp"
145  
-		:: "r"(main),"r"(lwp0.l_md.md_pcb->pcb_sf.sf_r7_bank));
  140
+		"b	%0"
  141
+		:: "r"(main));
146 142
 	/* NOTREACHED */
147 143
 	while (1)
148 144
 		;
149 145
 }
150 146
 
  147
+void lm32_lwp0_init(void)
  148
+{
  149
+	struct cpu_info *ci = curcpu();
  150
+
  151
+	lwp0.l_cpu = ci;
  152
+
  153
+	memset(&lwp0pcb, 0, sizeof(lwp0pcb));
  154
+	uvm_lwp_setuarea(&lwp0, (vaddr_t) &lwp0pcb);
  155
+
  156
+}
  157
+
151 158
 void
152 159
 consinit(void)
153 160
 {
@@ -166,7 +173,7 @@ cpu_startup(void)
166 173
 
167 174
 	strcpy(cpu_model, "LatticeMico32\n");
168 175
 
169  
-	lm32_startup();
  176
+//	lm32_startup();
170 177
 }
171 178
 
172 179
 SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
@@ -226,8 +233,8 @@ cpu_reboot(int howto, char *bootstr)
226 233
 	splhigh();
227 234
 
228 235
 	/* Do a dump if requested. */
229  
-	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
230  
-		dumpsys();
  236
+//	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
  237
+//		dumpsys();
231 238
 
232 239
  haltsys:
233 240
 	doshutdownhooks();
@@ -255,42 +262,3 @@ cpu_reboot(int howto, char *bootstr)
255 262
 		;
256 263
 	/*NOTREACHED*/
257 264
 }
258  
-
259  
-void
260  
-intc_intr(int ssr, int spc, int ssp)
261  
-{
262  
-	struct intc_intrhand *ih;
263  
-	int s, evtcode;
264  
-
265  
-	curcpu()->ci_data.cpu_nintr++;
266  
-
267  
-	evtcode = _reg_read_4(SH4_INTEVT);
268  
-
269  
-	ih = EVTCODE_IH(evtcode);
270  
-	KDASSERT(ih->ih_func);
271  
-	/*
272  
-	 * On entry, all interrrupts are disabled, and exception is enabled.
273  
-	 * Enable higher level interrupt here.
274  
-	 */
275  
-	s = _cpu_intr_resume(ih->ih_level);
276  
-
277  
-	if (evtcode == SH_INTEVT_TMU0_TUNI0) {	/* hardclock */
278  
-		struct clockframe cf;
279  
-		cf.spc = spc;
280  
-		cf.ssr = ssr;
281  
-		cf.ssp = ssp;
282  
-		(*ih->ih_func)(&cf);
283  
-	} else {
284  
-		(*ih->ih_func)(ih->ih_arg);
285  
-	}
286  
-}
287  
-
288  
-#ifdef MODULAR
289  
-/*
290  
- * Push any modules loaded by the bootloader etc.
291  
- */
292  
-void
293  
-module_init_md(void)
294  
-{
295  
-}
296  
-#endif

No commit comments for this range

Something went wrong with that request. Please try again.