Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: fallen/NetBSD
base: f4cabad74189
...
head fork: fallen/NetBSD
compare: 1dabf3fa0441
  • 5 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
1  sys/arch/lm32/conf/files.lm32
View
@@ -3,3 +3,4 @@ include "arch/lm32/conf/majors.lm32"
file arch/lm32/lm32/pmap.c
file arch/lm32/lm32/copy.c
file arch/lm32/lm32/lock_stubs.S
+file arch/lm32/lm32/mmu.c
16 sys/arch/lm32/include/cpu.h
View
@@ -61,6 +61,22 @@
struct intrsource;
struct pmap;
+#define lm32_dcache_invalidate() do { \
+ asm volatile("wcsr DCC, r0"); \
+ } while(0);
+
+#define lm32_icache_invalidate() do { \
+ asm volatile("wcsr ICC, r0\n" \
+ "nop\n" \
+ "nop\n" \
+ "nop\n" \
+ "nop\n"); \
+ } while(0);
+
+
+void lm32_dtlb_invalidate_line(vaddr_t vaddr);
+void lm32_itlb_invalidate_line(vaddr_t vaddr);
+
/*
* a bunch of this belongs in cpuvar.h; move it later..
*/
4 sys/arch/lm32/include/vmparam.h
View
@@ -41,7 +41,7 @@
#include <sys/mutex.h>
-#define PAGE_SHIFT 12
+#define PAGE_SHIFT (12)
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK (PAGE_SIZE - 1)
@@ -104,4 +104,6 @@
#define VM_FREELIST_FIRST16 1
#define VM_FREELIST_DEFAULT 0
+#define lm32_ptob(x) ((uint32_t)(x) << PGSHIFT)
+
#endif /* _LM32_VMPARAM_H_ */
87 sys/arch/lm32/lm32/copy.c
View
@@ -11,6 +11,8 @@
void do_pmap_load(void);
int copyout(const void *kaddr, void *uaddr, size_t len);
int copyin(const void *uaddr, void *kaddr, size_t len);
+int copyinstr(const void *from, void *to, size_t max_len, size_t *len_copied);
+int copystr(const void *kfaddr, void *kdaddr, size_t maxlen, size_t *done);
void do_pmap_load(void)
{
@@ -98,3 +100,88 @@ int copyout(const void *kaddr, void *uaddr, size_t len)
return 0;
}
+
+int copyinstr(const void *from, void *to, size_t max_len, size_t *len_copied)
+{
+ const char *from_8 = (const char *)from;
+ char *to_8 = (char *)to;
+ int ret = 0;
+ size_t maxlen_temp = max_len;
+
+ if ( curcpu()->ci_want_pmapload )
+ do_pmap_load();
+
+ if ((size_t)from > VM_MAXUSER_ADDRESS) /* to be checked, jump if carry ? */
+ {
+ ret = EFAULT;
+ goto copyinstr_return;
+ }
+
+ if (max_len > VM_MAXUSER_ADDRESS - (size_t)from)
+ max_len = VM_MAXUSER_ADDRESS - (size_t)from;
+
+ maxlen_temp++;
+
+ do
+ {
+ if (--maxlen_temp == 0)
+ {
+ ret = 1;
+ break;
+ }
+ *to_8++ = *from_8;
+ } while (*from_8++ != '\0');
+
+
+ if (ret)
+ {
+ if (VM_MAXUSER_ADDRESS >= (size_t)from_8)
+ ret = EFAULT;
+ else
+ ret = ENAMETOOLONG;
+ }
+ else
+ {
+ maxlen_temp--;
+ ret = 0;
+ }
+
+copyinstr_return:
+ if (NULL != len_copied)
+ *len_copied = max_len - maxlen_temp;
+
+ return ret;
+}
+
+
+int copystr(const void *kfaddr, void *kdaddr, size_t maxlen, size_t *done)
+{
+ const char *from_8 = kfaddr;
+ char *to_8 = kdaddr;
+ size_t maxlen_temp = maxlen;
+ int ret = 0;
+
+ from_8--;
+ maxlen_temp++;
+
+ do
+ {
+ if (--maxlen_temp == 0)
+ {
+ ret = ENAMETOOLONG;
+ break;
+ }
+ *to_8++ = *from_8;
+ } while (*from_8++ != '\0');
+
+ if (ret == 0)
+ {
+ maxlen_temp--;
+ } else
+ ret = ENAMETOOLONG;
+
+ if (NULL != done)
+ *done = maxlen - maxlen_temp;
+
+ return ret;
+}
18 sys/arch/lm32/lm32/mmu.c
View
@@ -0,0 +1,18 @@
+
+/*
+ * COPYRIGHT (C) 2013 Yann Sionneau <yann.sionneau@gmail.com>
+ */
+
+#include <lm32/cpu.h>
+
+void lm32_dtlb_invalidate_line(vaddr_t vaddr)
+{
+ vaddr |= 0x21;
+ asm volatile ("wcsr tlbvaddr, %0" :: "r"(vaddr) : );
+}
+
+void lm32_itlb_invalidate_line(vaddr_t vaddr)
+{
+ vaddr |= 0x20;
+ asm volatile ("wcsr tlbvaddr, %0" :: "r"(vaddr) : );
+}
1  sys/arch/milkymist/conf/files.milkymist
View
@@ -22,5 +22,6 @@ attach uart at mainbus
file arch/milkymist/dev/uart.c uart needs-flag
file arch/milkymist/milkymist/intr.c
+file arch/milkymist/milkymist/machdep.c
include "arch/milkymist/conf/majors.milkymist"
2  sys/arch/milkymist/include/cpu.h
View
@@ -7,4 +7,6 @@ extern struct cpu_info cpu_info_store;
#include <lm32/cpu.h>
+#define CPU_CONSDEV 1
+
#endif
80 sys/arch/milkymist/milkymist/machdep.c
View
@@ -67,11 +67,6 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.43 2012/06/11 16:27:08 tsutsui Exp $");
-#include "opt_memsize.h"
-#include "scif.h"
-#include "opt_kloader.h"
-#include "opt_modular.h"
-
#include <sys/param.h>
#include <sys/systm.h>
#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 $")
#include <sys/module.h>
#include <machine/intr.h>
-#include <machine/kloader.h>
#include <machine/pcb.h>
#include <dev/cons.h>
-#include "ksyms.h"
-
/* the following is used externally (sysctl_hw) */
char machine[] = MACHINE;
char machine_arch[] = MACHINE_ARCH;
@@ -97,9 +89,14 @@ char machine_arch[] = MACHINE_ARCH;
/* Our exported CPU info; we can have only one. */
struct cpu_info cpu_info_store;
+static struct pcb lwp0pcb;
void main(void) __attribute__((__noreturn__));
void milkymist_startup(void) __attribute__((__noreturn__));
+void lm32_lwp0_init(void);
+
+#define IOM_RAM_BEGIN (0x40000000)
+#define IOM_RAM_SIZE (0x08000000) /* 128 MB of DDR SDRAM on the Milkymist One */
void
milkymist_startup(void)
@@ -111,21 +108,21 @@ milkymist_startup(void)
memset(edata, 0, end - edata);
/* Initialize CPU ops. */
- lm32_cpu_init();
+// lm32_cpu_init();
/* Console */
consinit();
/* Load memory to UVM */
physmem = atop(IOM_RAM_SIZE);
- kernend = atop(round_page(end));
+ kernend = atop(round_page((unsigned int)end));
uvm_page_physload(
kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
VM_FREELIST_DEFAULT);
/* Initialize proc0 u-area */
- lm32_proc0_init();
+ lm32_lwp0_init();
/* Initialize pmap and start to address translation */
pmap_bootstrap();
@@ -140,14 +137,24 @@ milkymist_startup(void)
/* Jump to main */
__asm volatile(
- "jmp @%0;"
- "mov %1, sp"
- :: "r"(main),"r"(lwp0.l_md.md_pcb->pcb_sf.sf_r7_bank));
+ "b %0"
+ :: "r"(main));
/* NOTREACHED */
while (1)
;
}
+void lm32_lwp0_init(void)
+{
+ struct cpu_info *ci = curcpu();
+
+ lwp0.l_cpu = ci;
+
+ memset(&lwp0pcb, 0, sizeof(lwp0pcb));
+ uvm_lwp_setuarea(&lwp0, (vaddr_t) &lwp0pcb);
+
+}
+
void
consinit(void)
{
@@ -166,7 +173,7 @@ cpu_startup(void)
strcpy(cpu_model, "LatticeMico32\n");
- lm32_startup();
+// lm32_startup();
}
SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
@@ -226,8 +233,8 @@ cpu_reboot(int howto, char *bootstr)
splhigh();
/* Do a dump if requested. */
- if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
- dumpsys();
+// if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
+// dumpsys();
haltsys:
doshutdownhooks();
@@ -255,42 +262,3 @@ cpu_reboot(int howto, char *bootstr)
;
/*NOTREACHED*/
}
-
-void
-intc_intr(int ssr, int spc, int ssp)
-{
- struct intc_intrhand *ih;
- int s, evtcode;
-
- curcpu()->ci_data.cpu_nintr++;
-
- evtcode = _reg_read_4(SH4_INTEVT);
-
- ih = EVTCODE_IH(evtcode);
- KDASSERT(ih->ih_func);
- /*
- * On entry, all interrrupts are disabled, and exception is enabled.
- * Enable higher level interrupt here.
- */
- s = _cpu_intr_resume(ih->ih_level);
-
- if (evtcode == SH_INTEVT_TMU0_TUNI0) { /* hardclock */
- struct clockframe cf;
- cf.spc = spc;
- cf.ssr = ssr;
- cf.ssp = ssp;
- (*ih->ih_func)(&cf);
- } else {
- (*ih->ih_func)(ih->ih_arg);
- }
-}
-
-#ifdef MODULAR
-/*
- * Push any modules loaded by the bootloader etc.
- */
-void
-module_init_md(void)
-{
-}
-#endif

No commit comments for this range

Something went wrong with that request. Please try again.