From cb7bb8ecebd186b6290cc0dfd24db62bb35789f3 Mon Sep 17 00:00:00 2001 From: jasper Date: Sat, 12 Jul 2014 20:36:52 +0000 Subject: [PATCH] - replace main() with mips_init() so we can save the arguments from uboot to pass it to the kernel later on. also use it to get the clock frequency. - implement getsecs() so the bootprompt timeout works input/ok miod@ pirofti@ --- sys/arch/octeon/stand/boot/libsa.h | 5 +++-- sys/arch/octeon/stand/boot/machdep.c | 30 ++++++++++++++++++++-------- sys/arch/octeon/stand/boot/start.S | 12 +++++++++-- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/sys/arch/octeon/stand/boot/libsa.h b/sys/arch/octeon/stand/boot/libsa.h index 90c6061b384..28b282cc7a1 100644 --- a/sys/arch/octeon/stand/boot/libsa.h +++ b/sys/arch/octeon/stand/boot/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.1 2013/06/05 01:02:29 jasper Exp $ */ +/* $OpenBSD: libsa.h,v 1.2 2014/07/12 20:36:52 jasper Exp $ */ /* * Copyright (c) 2013 Jasper Lievisse Adriaanse @@ -34,7 +34,6 @@ void run_loadfile(u_long *, int); /* * CN30XX UART */ - void cn30xxuartcnprobe(struct consdev *); void cn30xxuartcninit(struct consdev *); void cn30xxuartcnputc(dev_t, int); @@ -44,3 +43,5 @@ int cn30xxuartcngetc(dev_t); * clock */ void delay(int); +u_int cp0_get_count(void); + diff --git a/sys/arch/octeon/stand/boot/machdep.c b/sys/arch/octeon/stand/boot/machdep.c index 15c7482e908..78d6ae877a2 100644 --- a/sys/arch/octeon/stand/boot/machdep.c +++ b/sys/arch/octeon/stand/boot/machdep.c @@ -1,8 +1,8 @@ -/* $OpenBSD: machdep.c,v 1.2 2013/06/13 20:01:01 jasper Exp $ */ +/* $OpenBSD: machdep.c,v 1.3 2014/07/12 20:36:52 jasper Exp $ */ /* * Copyright (c) 2009, 2010 Miodrag Vallat. - * Copyright (c) 2013 Jasper Lievisse Adriaanse + * Copyright (c) 2013,2014 Jasper Lievisse Adriaanse * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -45,16 +45,28 @@ #include #include #include "libsa.h" +#include #include #include #include -#include +struct boot_desc *boot_desc; +struct boot_info *boot_info; + +/* + * We need to save the arguments u-boot setup for us, so we can pass them + * onwards to the kernel later on. + */ int -main() +mips_init(__register_t a0, __register_t a1, __register_t a2 __unused, + __register_t a3) { + boot_desc = (struct boot_desc *)a3; + boot_info = + (struct boot_info *)PHYS_TO_CKSEG0(boot_desc->boot_info_addr); + boot(0); - return (0); + return 0; } /* @@ -141,9 +153,12 @@ devboot(dev_t dev, char *path) } time_t -getsecs() +getsecs(void) { - return (0); + u_int ticks = cp0_get_count(); + uint32_t freq = boot_desc->eclock; + + return (time_t)((0xffffffff - ticks) / freq); } void @@ -158,4 +173,3 @@ _rtt() octeon_xkphys_write_8(OCTEON_CIU_BASE + CIU_SOFT_RST, 1); for (;;) ; } - diff --git a/sys/arch/octeon/stand/boot/start.S b/sys/arch/octeon/stand/boot/start.S index 136ab44f0b1..926c28588e7 100644 --- a/sys/arch/octeon/stand/boot/start.S +++ b/sys/arch/octeon/stand/boot/start.S @@ -1,4 +1,4 @@ -/* $OpenBSD: start.S,v 1.2 2013/06/05 01:09:09 jasper Exp $ */ +/* $OpenBSD: start.S,v 1.3 2014/07/12 20:36:52 jasper Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -38,6 +38,13 @@ .globl __start .globl kernel_text kernel_text = __start +LEAF(cp0_get_count, 0) + MFC0 v0, COP_0_COUNT + MFC0_HAZARD + j ra + NOP +END(cp0_get_count) + __start: /* initialize ebase */ dla t0, 0xffffffff80000000 @@ -71,7 +78,8 @@ __start: PTR_S ra, CF_RA_OFFS(t0) # save uboot return address PTR_S sp, 0(t0) # and stack move sp, t0 - jal main # main(argc, argv, envp, callvec, esym) + jal mips_init # mips_init(argc, argv, envp, + nop # callvec, esym) beqz v0, 1f # upon failure, return to uboot nop -- 2.20.1