Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: fallen/NetBSD
base: 81a01e8a3fdb
...
head fork: fallen/NetBSD
compare: aa55d256f30a
  • 4 commits
  • 34 files changed
  • 0 commit comments
  • 1 contributor
Showing with 756 additions and 41 deletions.
  1. +2 −0  etc/etc.milkymist/MAKEDEV.conf
  2. +10 −0 etc/etc.milkymist/Makefile.inc
  3. +11 −0 etc/etc.milkymist/ttys
  4. +6 −0 sys/arch/lm32/conf/files.lm32
  5. +14 −13 sys/arch/lm32/include/cpu.h
  6. +2 −1  sys/arch/lm32/include/cpu_counter.h
  7. +5 −1 sys/arch/lm32/include/frame.h
  8. +12 −0 sys/arch/lm32/include/intr.h
  9. +7 −2 sys/arch/lm32/include/proc.h
  10. +1 −0  sys/arch/lm32/include/reg.h
  11. +6 −0 sys/arch/lm32/lm32/copy.c
  12. +48 −0 sys/arch/lm32/lm32/cpu.c
  13. +58 −0 sys/arch/lm32/lm32/interrupt.c
  14. +29 −0 sys/arch/lm32/lm32/locore_subr.S
  15. +36 −0 sys/arch/lm32/lm32/process_machdep.c
  16. +24 −0 sys/arch/lm32/lm32/syscall.c
  17. +2 −0  sys/arch/milkymist/conf/GENERIC
  18. +4 −0 sys/arch/milkymist/conf/files.milkymist
  19. +5 −1 sys/arch/milkymist/conf/majors.milkymist
  20. +4 −1 sys/arch/milkymist/conf/std.milkymist
  21. +25 −0 sys/arch/milkymist/dev/timer.c
  22. +77 −0 sys/arch/milkymist/dev/uart.c
  23. +31 −0 sys/arch/milkymist/include/autoconf.h
  24. +24 −0 sys/arch/milkymist/include/csr.h
  25. +9 −1 sys/arch/milkymist/include/intr.h
  26. +2 −16 sys/arch/milkymist/include/irqhandler.h
  27. +6 −0 sys/arch/milkymist/include/uart.h
  28. +56 −0 sys/arch/milkymist/milkymist/autoconf.c
  29. +117 −0 sys/arch/milkymist/milkymist/clock.c
  30. +11 −0 sys/arch/milkymist/milkymist/intr.c
  31. +2 −2 sys/arch/milkymist/milkymist/locore.s
  32. +23 −3 sys/arch/milkymist/milkymist/machdep.c
  33. +72 −0 sys/arch/milkymist/milkymist/mainbus.c
  34. +15 −0 sys/arch/milkymist/milkymist/sys_machdep.c
View
2  etc/etc.milkymist/MAKEDEV.conf
@@ -0,0 +1,2 @@
+# $NetBSD: MAKEDEV.conf,v 1.11 2011/09/06 14:40:10 apb Exp $
+
View
10 etc/etc.milkymist/Makefile.inc
@@ -0,0 +1,10 @@
+# $NetBSD: Makefile.inc,v 1.27 2012/07/09 18:12:11 ysionneau Exp $
+#
+# etc.milkymist/Makefile.inc -- milkymist-specific etc Makefile targets
+#
+
+# If you change the list of distributed kernels, don't forget
+# to update the release documentation in distrib/notes/common/contents
+
+KERNEL_SETS= GENERIC
+
View
11 etc/etc.milkymist/ttys
@@ -0,0 +1,11 @@
+#
+# $NetBSD: ttys,v 1.24 2012/06/13 20:49:12 martin Exp $
+#
+# from: @(#)ttys 5.1 (Berkeley) 4/17/89
+#
+# name getty type status comments
+#
+# If the console is marked insecure, single-user requires
+# the root password.
+console "/usr/libexec/getty Pc" wsvt25 on secure
+constty "/usr/libexec/getty Pc" wsvt25 off secure
View
6 sys/arch/lm32/conf/files.lm32
@@ -2,4 +2,10 @@ include "arch/lm32/conf/majors.lm32"
file arch/lm32/lm32/pmap.c
file arch/lm32/lm32/copy.c
+file arch/lm32/lm32/cpu.c
+file arch/lm32/lm32/syscall.c
+file arch/lm32/lm32/process_machdep.c
+file arch/lm32/lm32/interrupt.c
file arch/lm32/lm32/lock_stubs.S
+file arch/lm32/lm32/locore_subr.S
+file dev/cons.c
View
27 sys/arch/lm32/include/cpu.h
@@ -182,8 +182,6 @@ extern struct cpu_info cpu_info_store;
#define CPU_STOP(_ci) ((_ci)->ci_func->stop(_ci))
#define CPU_START_CLEANUP(_ci) ((_ci)->ci_func->cleanup(_ci))
-#define aston(l, why) ((l)->l_md.md_astpending |= (why))
-
void cpu_boot_secondary_processors(void);
void cpu_init_idle_lwps(void);
void cpu_init_msrs(struct cpu_info *, bool);
@@ -206,13 +204,16 @@ struct clockframe {
#define CLKF_USERMODE(framep) (0)
#define CLKF_PC(framep) ((framep)->tf_pc)
#define CLKF_INTR(framep) (0)
+#define aston(l) do { (l)->l_md.md_astpending = 1; } while(0)
-/*
- * Give a profiling tick to the current process when the user profiling
- * buffer pages are invalid. On the i386, request an ast to send us
- * through trap(), marking the proc as needing a profiling tick.
- */
-extern void cpu_need_proftick(struct lwp *l);
+#define cpu_need_proftick(l) do { (l)->l_pflag |= LP_OWEUPC; aston(l); } while (0)
+
+#define cpu_need_resched(ci, flags) \
+do { \
+ ci->ci_want_resched = 1; \
+ if (curlwp != ci->ci_data.cpu_idlelwp) \
+ aston(curlwp); \
+} while (/*CONSTCOND*/0)
/*
* Notify the LWP l that it has a signal pending, process as soon as
@@ -223,18 +224,18 @@ extern void cpu_signotify(struct lwp *);
/*
* We need a machine-independent name for this.
*/
-extern void (*delay_func)(unsigned int);
+void delay_func(unsigned int);
struct timeval;
-#define DELAY(x) (*delay_func)(x)
-#define delay(x) (*delay_func)(x)
+#define DELAY(x) delay_func(x)
+#define delay(x) delay_func(x)
extern int cputype;
extern int cpuid_level;
extern int cpu_class;
-extern void (*lm32_cpu_idle)(void);
-#define cpu_idle() (*lm32_cpu_idle)()
+void lm32_cpu_idle(void);
+#define cpu_idle() lm32_cpu_idle()
/* machdep.c */
void dumpconf(void);
View
3  sys/arch/lm32/include/cpu_counter.h
@@ -38,7 +38,8 @@ uint64_t cpu_counter(void);
uint64_t cpu_counter_serializing(void);
uint32_t cpu_counter32(void);
uint64_t cpu_frequency(struct cpu_info *);
-int cpu_hascounter(void);
+//int cpu_hascounter(void);
+#define cpu_hascounter() (0)
#endif /* _KERNEL */
View
6 sys/arch/lm32/include/frame.h
@@ -71,6 +71,8 @@
#include <lm32/signal.h>
#include <sys/ucontext.h>
#include <sys/siginfo.h>
+#include <lm32/reg.h>
+
/*
* New-style signal frame
*/
@@ -83,7 +85,9 @@ struct sigframe_siginfo {
ucontext_t sf_uc; /* actual saved ucontext */
};
-
+struct trapframe {
+ struct reg tf_regs;
+};
void *getframe(struct lwp *, int, int *);
void buildcontext(struct lwp *, int, void *, void *);
View
12 sys/arch/lm32/include/intr.h
@@ -33,5 +33,17 @@ static __inline void _set_irq_mask(int mask)
__asm volatile ("wcsr IM, %0" :: "r"(mask) : );
}
+static __inline void _ack_irq(unsigned int irq)
+{
+ unsigned int __ip;
+ asm volatile("rcsr %0, IP\n\t"
+ "or %0, %0, %1\n\t"
+ "wcsr IP, %0" : "=&r"(__ip) : "r"(irq) : );
+}
+
+void lm32_intrhandler_register(int irqmask, int (*func)(void *));
+void init_irqhandlers_array(void);
+unsigned int lm32_dispatch_irq(unsigned int irq_pending_mask, void *arg);
+
#endif
#endif
View
9 sys/arch/lm32/include/proc.h
@@ -40,7 +40,7 @@
struct mdlwp {
volatile int md_flags;
volatile int md_astpending;
- struct trapframe *md_utf; /* user trampframe */
+ struct trapframe md_utf; /* user trampframe */
};
struct trapframe;
@@ -53,7 +53,12 @@ struct mdproc {
//#define LWP0_CPU_INFO &cpu_info[0]
#define LWP0_MD_INITIALIZER { \
.md_flags = 0, \
- .md_utf = (void *)0xdeadbeef, \
+ .md_utf = { \
+ .tf_regs = { .r_regs = { 0 }, \
+ .r_ra = 0, \
+ .r_ea = 0, \
+ .r_ba = 0, \
+ .r_pc = 0} } \
}
#endif /* _KERNEL */
View
1  sys/arch/lm32/include/reg.h
@@ -49,6 +49,7 @@ struct reg {
int r_ra;
int r_ea;
int r_ba;
+ int r_pc;
};
/*
View
6 sys/arch/lm32/lm32/copy.c
@@ -185,3 +185,9 @@ int copystr(const void *kfaddr, void *kdaddr, size_t maxlen, size_t *done)
return ret;
}
+
+int copyoutstr(const void *from, void *to, size_t maxlen, size_t *done)
+{
+ return 0;
+ //TODO
+}
View
48 sys/arch/lm32/lm32/cpu.c
@@ -0,0 +1,48 @@
+#include <lm32/cpu.h>
+#include <sys/cpu.h>
+#include <lm32/reg.h>
+#include <sys/exec.h>
+
+void
+cpu_intr_redistribute(void)
+{
+
+ /* XXX nothing */
+}
+
+u_int cpu_intr_count(struct cpu_info *ci)
+{
+ return ci->ci_nintrhand;
+}
+
+void cpu_offline_md(void)
+{
+ /* XXX nothing */
+}
+
+
+/*
+ * Clear registers on exec
+ */
+void
+setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack)
+{
+// struct pmap *pmap = vm_map_pmap(&l->l_proc->p_vmspace->vm_map);
+ struct reg *regs;
+ int i;
+
+ regs = &l->l_md.md_utf.tf_regs;
+ for (i = R1 ; i <= R27 ; i++)
+ regs->r_regs[i] = 0;
+
+ regs->r_pc = pack->ep_entry;
+ regs->r_regs[R28] = stack; // R28: stack pointer
+}
+
+
+//TODO: use Milkymist SoC timer to provide more precise delay function?
+void delay_func(unsigned int n)
+{
+ unsigned int i = n;
+ while(i-- > 0);
+}
View
58 sys/arch/lm32/lm32/interrupt.c
@@ -0,0 +1,58 @@
+/*
+ * COPYRIGHT (C) 2013 Yann Sionneau <yann.sionneau@gmail.com>
+ */
+
+#include <lib/libkern/libkern.h>
+#include <machine/psl.h>
+
+struct irqhandler {
+ unsigned int mask;
+ int (*irq_handler)(void *);
+};
+
+struct irqhandler irqhandlers[32];
+
+void init_irqhandlers_array(void)
+{
+ memset(irqhandlers, 0, sizeof(irqhandlers));
+}
+
+unsigned int lm32_dispatch_irq(unsigned int irq_pending_mask, void *arg)
+{
+ unsigned int i;
+ int s;
+
+ for (i = 0 ; i < 32 ; i++)
+ {
+ if ((irq_pending_mask & irqhandlers[i].mask)
+ && (irqhandlers[i].irq_handler != NULL))
+ {
+ s = spl0();
+ if (irqhandlers[i].irq_handler(arg))
+ {
+ splx(s);
+ return 1;
+ }
+ splx(s);
+ }
+ }
+
+ printf("spurious IRQ or no handler registered for this IRQ: IP == 0x%08X\n", irq_pending_mask);
+ return 0;
+}
+
+void lm32_intrhandler_register(int irqmask, int (*func)(void *))
+{
+ unsigned int i;
+ for (i = 0 ; i < 32 ; i++)
+ {
+ if (irqhandlers[i].irq_handler == NULL)
+ {
+ irqhandlers[i].mask = irqmask;
+ irqhandlers[i].irq_handler = func;
+ return;
+ }
+ }
+
+ panic("No more slot to register irq handler\n");
+}
View
29 sys/arch/lm32/lm32/locore_subr.S
@@ -0,0 +1,29 @@
+/*
+ * COPYRIGHT (C) 2013 Yann Sionneau <yann.sionneau@gmail.com>
+ */
+
+#include <lm32/asm.h>
+
+// TODO: implement suword
+ENTRY(suword)
+
+// TODO: implement susword
+ENTRY(susword)
+
+// TODO: implement suswintr
+ENTRY(suswintr)
+
+// TODO: implement subyte
+ENTRY(subyte)
+
+// TODO: implement fuswintr
+ENTRY(fuswintr)
+
+// TODO: implement kcopy
+ENTRY(kcopy)
+
+// TODO: implement setjmp
+ENTRY(setjmp)
+
+// TODO: implement longjmp
+ENTRY(longjmp)
View
36 sys/arch/lm32/lm32/process_machdep.c
@@ -0,0 +1,36 @@
+#include <sys/param.h>
+#include <sys/cdefs.h>
+#include <sys/cpu.h>
+#include <sys/proc.h>
+#include <sys/ptrace.h>
+#include <sys/systm.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <lm32/pcb.h>
+#include <lm32/psl.h>
+#include <lm32/reg.h>
+
+int
+process_set_pc(struct lwp *l, void *addr)
+{
+ return 0;
+}
+
+int
+process_sstep(struct lwp *l, int sstep)
+{
+ return 0;
+}
+
+int
+process_read_regs(struct lwp *l, struct reg *regs)
+{
+ return 0;
+}
+
+int
+process_write_regs(struct lwp *l, const struct reg *regs)
+{
+ return 0;
+}
View
24 sys/arch/lm32/lm32/syscall.c
@@ -0,0 +1,24 @@
+#include <sys/param.h>
+#include <sys/cpu.h>
+#include <sys/ktrace.h>
+#include <sys/proc.h>
+#include <sys/reboot.h>
+#include <sys/systm.h>
+#include <sys/syscallvar.h>
+#include <sys/syscall.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <lm32/frame.h>
+#include <lm32/pcb.h>
+#include <lm32/reg.h>
+
+void
+child_return(void *arg)
+{
+ struct lwp * const l = arg;
+ struct trapframe * const tf = &l->l_md.md_utf;
+
+ tf->tf_regs.r_regs[R1] = 0; // set return value to 0 as the result of fork() for the child
+ ktrsysret(SYS_fork, 0, 0);
+}
View
2  sys/arch/milkymist/conf/GENERIC
@@ -10,4 +10,6 @@ file-system PTYFS
file-system KERNFS
file-system FDESC
+pseudo-device pty # pseudo-terminals
+
config netbsd root on ? type ?
View
4 sys/arch/milkymist/conf/files.milkymist
@@ -7,6 +7,7 @@ maxusers 2 8 64
device mainbus {}
attach mainbus at root
+file arch/milkymist/milkymist/mainbus.c
device cpu
attach cpu at mainbus
@@ -23,5 +24,8 @@ file arch/milkymist/dev/uart.c uart needs-flag
file arch/milkymist/milkymist/intr.c
file arch/milkymist/milkymist/machdep.c
+file arch/milkymist/milkymist/sys_machdep.c
+file arch/milkymist/milkymist/autoconf.c
+file arch/milkymist/milkymist/clock.c
include "arch/milkymist/conf/majors.milkymist"
View
6 sys/arch/milkymist/conf/majors.milkymist
@@ -1 +1,5 @@
-device-major mem char 2
+device-major cons char 0
+device-major mem char 1
+device-major pts char 2 pty
+device-major ptc char 3 pty
+device-major swap char 4 block 1 vmswap
View
5 sys/arch/milkymist/conf/std.milkymist
@@ -1,5 +1,8 @@
-machine milkymist lm32
+# $NetBSD: std.lm32,v 1.33 2012/09/27 18:28:55 ysionneau Exp $
+#
+# standard, required NetBSD/milkymist 'options'
+machine milkymist lm32
include "conf/std" # MI standard options
include "arch/lm32/conf/std.lm32" # lm32 standard options
View
25 sys/arch/milkymist/dev/timer.c
@@ -0,0 +1,25 @@
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.11 2010/11/21 18:53:56 ysionneau Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <machine/autoconf.h>
+
+static int timer_match(device_t, cfdata_t, void*);
+static void timer_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(timer, 0,
+ timer_match, timer_attach, NULL, NULL);
+
+int
+timer_match(device_t parent, cfdata_t cf, void *aux)
+{
+ return 1;
+}
+
+void
+timer_attach(device_t parent, device_t self, void *aux)
+{
+ aprint_normal("\n");
+}
View
77 sys/arch/milkymist/dev/uart.c
@@ -0,0 +1,77 @@
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: uart.c,v 1.11 2010/11/21 18:53:56 ysionneau Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <dev/cons.h>
+
+#include <machine/autoconf.h>
+#include <machine/uart.h>
+
+static int uart_match(device_t, cfdata_t, void*);
+static void uart_attach(device_t, device_t, void *);
+
+/* Console functions */
+static int milkymist_com_cngetc(dev_t);
+static void milkymist_com_cnputc(dev_t, int);
+static void milkymist_com_cnpollc(dev_t, int);
+
+static struct cnm_state milkymist_com_cnm_state;
+
+CFATTACH_DECL_NEW(uart, 0,
+ uart_match, uart_attach, NULL, NULL);
+
+int
+uart_match(device_t parent, cfdata_t cf, void *aux)
+{
+ return 1;
+}
+
+void
+uart_attach(device_t parent, device_t self, void *aux)
+{
+ aprint_normal("\n");
+}
+
+//TODO: implement com_cngetc
+static int milkymist_com_cngetc(dev_t dev)
+{
+ return 1;
+}
+
+//TODO: implement com_cnputc
+static void milkymist_com_cnputc(dev_t dev, int c)
+{
+
+}
+
+//TODO:implement com_cnpollc
+static void milkymist_com_cnpollc(dev_t dev, int on)
+{
+
+}
+
+/* console method struct */
+struct consdev milkymist_com_cons =
+{
+ NULL, /* cn_probe: probe hardware and fill in consdev info */
+ NULL, /* cn_init: turn on as console */
+ milkymist_com_cngetc, /* cn_getc: kernel getchar interface */
+ milkymist_com_cnputc, /* cn_putc: kernel putchar interface */
+ milkymist_com_cnpollc, /* cn_pollc: turn on and off polling */
+ NULL, /* cn_bell: ring bell */
+ NULL, /* cn_halt: stop device */
+ NULL, /* cn_flush: flush output */
+ NODEV, /* major/minor of device */
+ CN_NORMAL /* priority */
+};
+
+int milkymist_uart_cnattach(void)
+{
+ cn_tab = &milkymist_com_cons;
+ cn_init_magic(&milkymist_com_cnm_state);
+
+ return 0;
+}
View
31 sys/arch/milkymist/include/autoconf.h
@@ -0,0 +1,31 @@
+/* $NetBSD: autoconf.h,v 1.4 2008/04/28 20:23:16 ysionneau Exp $ */
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+struct mainbus_attach_args {
+ const char *ma_name;
+};
View
24 sys/arch/milkymist/include/csr.h
@@ -0,0 +1,24 @@
+#ifndef _MACHINE_CSR_H_
+#define _MACHINE_CSR_H_
+
+#ifdef __ASSEMBLER__
+#define MMPTR(x) x
+#else
+#define MMPTR(x) (*((volatile unsigned int *)(x)))
+#endif
+
+void milkymist_write_csr(int addr, int value);
+int milkymist_read_csr(int addr);
+
+#define CSR_TIMER0_CONTROL MMPTR(0xe0001010)
+#define CSR_TIMER0_COMPARE MMPTR(0xe0001014)
+#define CSR_TIMER0_COUNTER MMPTR(0xe0001018)
+
+#define CSR_TIMER1_CONTROL MMPTR(0xe0001020)
+#define CSR_TIMER1_COMPARE MMPTR(0xe0001024)
+#define CSR_TIMER1_COUNTER MMPTR(0xe0001028)
+
+#define TIMER_ENABLE (0x01)
+#define TIMER_AUTORESTART (0x02)
+
+#endif
View
10 sys/arch/milkymist/include/intr.h
@@ -72,6 +72,13 @@ static __inline void _mask_irq(int irq_mask)
_set_irq_mask( old_mask & ~(irq_mask) );
}
+static __inline void _unmask_irq(int irq_mask)
+{
+ int old_mask = _get_irq_mask();
+ _set_irq_mask( old_mask & irq_mask);
+}
+
+
typedef int ipl_t;
typedef struct {
ipl_t _ipl;
@@ -96,6 +103,7 @@ splraiseipl(ipl_cookie_t icookie)
return _splraise(icookie._ipl);
}
-#include <machine/irqhandler.h>
+//#include <machine/irqhandler.h>
+void __isr(void);
#endif /* _MACHINE_INTR_H */
View
18 sys/arch/milkymist/include/irqhandler.h
@@ -44,6 +44,7 @@
#define _MACHINE_IRQHANDLER_H_
#include <sys/evcnt.h>
+#include <lm32/intr.h>
/* Define the IRQ bits */
@@ -68,24 +69,9 @@
#define IRQ_INSTRUCT -1
#define NIRQS 0x10 // 16 IRQs
-typedef struct irqhandler {
- int (*ih_func)(void *arg); /* handler function */
- void *ih_arg; /* Argument to handler */
- int ih_level; /* Interrupt level */
- int ih_num; /* Interrupt number (for accounting) */
- u_int ih_flags; /* Interrupt flags */
- u_int ih_maskaddr; /* mask address for expansion cards */
- u_int ih_maskbits; /* interrupt bit for expansion cards */
- struct irqhandler *ih_next; /* next handler */
- struct evcnt ih_ev; /* evcnt structure */
- int (*ih_realfunc)(void *arg); /* XXX real handler function */
- void *ih_realarg;
-} irqhandler_t;
-
#ifdef _KERNEL
extern u_int irqmasks[NIPL];
-extern irqhandler_t *irqhandlers[NIRQS];
-
+typedef struct irqhandler irqhandler_t;
void irq_init(void);
int irq_claim(int, irqhandler_t *, const char *group, const char *name);
int irq_release(int, irqhandler_t *);
View
6 sys/arch/milkymist/include/uart.h
@@ -0,0 +1,6 @@
+#ifndef _MACHINE_UART_H_
+#define _MACHINE_UART_H_
+
+int milkymist_uart_cnattach(void);
+
+#endif
View
56 sys/arch/milkymist/milkymist/autoconf.c
@@ -0,0 +1,56 @@
+/* $NetBSD: autoconf.c,v 1.10 2012/07/29 18:05:40 ysionneau Exp $ */
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.10 2012/07/29 18:05:40 ysionneau Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+
+void
+cpu_configure(void)
+{
+ /* Start configuration */
+ splhigh();
+
+ if (config_rootfound("mainbus", NULL) == NULL)
+ panic("no mainbus found");
+
+ /* Configuration is finished, turn on interrupts. */
+ spl0();
+}
+
+void
+cpu_rootconf(void)
+{
+
+ /* No boot information */
+ rootconf();
+}
View
117 sys/arch/milkymist/milkymist/clock.c
@@ -0,0 +1,117 @@
+/*
+ * COPYRIGHT (C) 2013 Yann Sionneau <yann.sionneau@gmail.com>
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/time.h>
+#include <sys/device.h>
+
+#include <machine/intr.h>
+#include <machine/csr.h>
+
+#include <opt_hz.h> /* for HZ */
+
+#define DEBUG_CLK
+#ifdef DEBUG_CLK
+#define DPRINTF(fmt...) printf(fmt)
+#else
+#define DPRINTF(fmt...)
+#endif
+
+#define SYSCLK_FREQ (80000000)
+#define TIMER0_MAX_VALUE (SYSCLK_FREQ / HZ)
+#define MILKYMIST_USEC_PER_TICK (1000000 / HZ)
+
+static int milkymist_clock_match(struct device *, struct cfdata *, void *);
+static void milkymist_clock_attach(struct device *, struct device *, void *);
+
+struct milkymist_clock_softc {
+ struct device device;
+ int sc_intr;
+};
+
+static struct milkymist_clock_softc *milkymist_clock_sc = NULL;
+
+static int
+milkymist_clock_match(struct device *parent, struct cfdata *match, void *aux)
+{
+ DPRINTF("milkymist_clock_match\n");
+ return 1;
+}
+
+static void
+milkymist_clock_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct milkymist_clock_softc *sc = (struct milkymist_clock_softc*) self;
+
+ DPRINTF("milkymist_clk_attach\n");
+
+ if (milkymist_clock_sc == NULL)
+ milkymist_clock_sc = sc;
+}
+
+CFATTACH_DECL_NEW(milkymist_clock, sizeof(struct milkymist_clock_softc), milkymist_clock_match,
+ milkymist_clock_attach, NULL, NULL);
+
+// TODO: what is this supposed to do?
+// A lot of port let this empty
+void
+setstatclockrate(int hertz)
+{
+
+}
+
+static __inline void milkymist_timer0_enable_irq(void)
+{
+ _unmask_irq(TIMER0_IRQ);
+}
+
+static __inline void milkymist_timer0_disable_irq(void)
+{
+ _mask_irq(TIMER0_IRQ);
+}
+
+/*
+ * milkymist_clock_intr:
+ *
+ *Handle the hardclock interrupt.
+ */
+static int
+milkymist_clock_intr(void *arg)
+{
+
+ DPRINTF("clock ticked!\n");
+ _ack_irq(TIMER0_IRQ);
+ return 1;
+}
+
+/*
+ * cpu_initclocks:
+ *
+ *Initialize the clock and get it going.
+ */
+void
+cpu_initclocks(void)
+{
+ struct milkymist_clock_softc *sc = milkymist_clock_sc;
+
+ stathz = profhz = 0;
+
+ /* set up and enable timer 0 as kernel timer, */
+ /* using 88 MHz cpu clock source */
+
+ /* register interrupt handler */
+ lm32_intrhandler_register(sc->sc_intr, milkymist_clock_intr);
+
+ /* Enable interrupts from timer 1 */
+ milkymist_timer0_enable_irq();
+
+ /* load max value of the timer */
+ CSR_TIMER0_COMPARE = TIMER0_MAX_VALUE;
+
+ /* start the timer */
+ CSR_TIMER0_CONTROL = TIMER_ENABLE;
+}
View
11 sys/arch/milkymist/milkymist/intr.c
@@ -30,3 +30,14 @@ ipl_t _splraise(ipl_t level)
return olevel;
}
+
+void __isr(void)
+{
+ unsigned int irq_pending_mask;
+
+ asm volatile("rcsr %0, IP" : "=r"(irq_pending_mask) :: );
+
+//TODO: make sure we pass trapframe as argument to irq and lm32_dispatch_irq
+ lm32_dispatch_irq(irq_pending_mask, NULL);
+
+}
View
4 sys/arch/milkymist/milkymist/locore.s
@@ -35,9 +35,9 @@ _reset_handler:
mvhi r1, hi(_reset_handler)
ori r1, r1, lo(_reset_handler)
wcsr EBA, r1
- calli _sdram_init
xor r2, r2, r2
bi _crt0
+ nop
_breakpoint_handler:
bi _breakpoint_handler
@@ -92,7 +92,7 @@ _divide_by_zero_handler:
_interrupt_handler:
sw (sp+0), ra
calli .save_all
- calli isr
+ calli __isr
bi .restore_all_and_eret
nop
nop
View
26 sys/arch/milkymist/milkymist/machdep.c
@@ -79,13 +79,14 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.43 2012/06/11 16:27:08 tsutsui Exp $")
#include <machine/intr.h>
#include <machine/pcb.h>
+#include <machine/uart.h>
#include <dev/cons.h>
/* the following is used externally (sysctl_hw) */
char machine[] = MACHINE;
char machine_arch[] = MACHINE_ARCH;
-
+char cpu_model[30];
/* Our exported CPU info; we can have only one. */
struct cpu_info cpu_info_store;
@@ -158,13 +159,16 @@ void lm32_lwp0_init(void)
void
consinit(void)
{
- static int initted;
+ static int initted = 0;
if (initted)
return;
initted = 1;
- cninit();
+ if (milkymist_uart_cnattach())
+ {
+ panic("Cannot init Milkymist serial console");
+ }
}
void
@@ -192,6 +196,12 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
}
+void cpu_reset(void)
+{
+ asm volatile("rcsr r11, EBA\n\t"
+ "b r11" ::: "r11" );
+}
+
void
cpu_reboot(int howto, char *bootstr)
{
@@ -262,3 +272,13 @@ cpu_reboot(int howto, char *bootstr)
;
/*NOTREACHED*/
}
+
+void lm32_cpu_idle(void)
+{
+ asm volatile("nop");
+}
+
+void
+cpu_dumpconf(void)
+{
+}
View
72 sys/arch/milkymist/milkymist/mainbus.c
@@ -0,0 +1,72 @@
+/* $NetBSD: mainbus.c,v 1.11 2010/11/21 18:53:56 ysionneau Exp $ */
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.11 2010/11/21 18:53:56 ysionneau Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <machine/autoconf.h>
+
+static int mainbus_match(device_t, cfdata_t, void *);
+static void mainbus_attach(device_t, device_t, void *);
+static int mainbus_print(void *, const char *);
+
+static struct mainbus_attach_args mainbusdevs[] = {
+ { "cpu" },
+ { NULL } /* terminator */
+};
+
+CFATTACH_DECL_NEW(mainbus, 0,
+ mainbus_match, mainbus_attach, NULL, NULL);
+
+int
+mainbus_match(device_t parent, cfdata_t cf, void *aux)
+{
+
+ return 1;
+}
+
+void
+mainbus_attach(device_t parent, device_t self, void *aux)
+{
+ struct mainbus_attach_args *ma;
+
+ aprint_normal("\n");
+
+ for (ma = mainbusdevs; ma->ma_name != NULL; ma++)
+ config_found(self, ma, mainbus_print);
+}
+
+int
+mainbus_print(void *aux, const char *pnp)
+{
+
+ return pnp ? QUIET : UNCONF;
+}
View
15 sys/arch/milkymist/milkymist/sys_machdep.c
@@ -0,0 +1,15 @@
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <sys/cpu.h>
+#include <uvm/uvm_extern.h>
+
+int
+sys_sysarch(struct lwp *l, const struct sys_sysarch_args *uap, register_t *retval)
+{
+ /*
+ * Currently no special system calls
+ */
+ return (ENOSYS);
+}

No commit comments for this range

Something went wrong with that request. Please try again.