From: aoyama Date: Mon, 13 Mar 2023 11:59:39 +0000 (+0000) Subject: Add "machine poweroff" command on luna88k bootloader. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bbda1dccca61f7629c0f983819d91b9d5f88866a;p=openbsd Add "machine poweroff" command on luna88k bootloader. ok miod@ --- diff --git a/sys/arch/luna88k/stand/boot/Makefile b/sys/arch/luna88k/stand/boot/Makefile index 15b0569aff2..8d9033fc595 100644 --- a/sys/arch/luna88k/stand/boot/Makefile +++ b/sys/arch/luna88k/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.17 2023/02/24 23:36:11 aoyama Exp $ +# $OpenBSD: Makefile,v 1.18 2023/03/13 11:59:39 aoyama Exp $ # $NetBSD: Makefile,v 1.9 2013/01/22 15:48:40 tsutsui Exp $ # @(#)Makefile 8.2 (Berkeley) 8/15/93 @@ -36,6 +36,7 @@ SRCS+= sio.c SRCS+= bmc.c bmd.c font.c kbd.c SRCS+= sc.c sd.c SRCS+= ufs_disksubr.c +SRCS+= cmd_luna88k.c SRCS+= logo.c # netboot support diff --git a/sys/arch/luna88k/stand/boot/cmd_luna88k.c b/sys/arch/luna88k/stand/boot/cmd_luna88k.c new file mode 100644 index 00000000000..08e49650e3a --- /dev/null +++ b/sys/arch/luna88k/stand/boot/cmd_luna88k.c @@ -0,0 +1,58 @@ +/* $OpenBSD: cmd_luna88k.c,v 1.1 2023/03/13 11:59:39 aoyama Exp $ */ +/* + * Copyright (c) 2023 Kenji Aoyama + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include +#include + +static int Xpoweroff(void); + +const struct cmd_table cmd_machine[] = { + { "poweroff", CMDT_CMD, Xpoweroff }, + { NULL, 0 } +}; + +struct pio { + volatile u_int8_t portA; + volatile unsigned : 24; + volatile u_int8_t portB; + volatile unsigned : 24; + volatile u_int8_t portC; + volatile unsigned : 24; + volatile u_int8_t cntrl; + volatile unsigned : 24; +}; + +#define PIO1_POWER 0x04 +#define PIO1_DISABLE 0x00 + +static int +Xpoweroff(void) +{ + struct pio *p1 = (struct pio *)OBIO_PIO1_BASE; + + printf("attempting to power down...\n"); + + p1->cntrl = (PIO1_POWER << 1) | PIO1_DISABLE; + *(volatile u_int8_t *)&p1->portC; + + DELAY(1000000); /* wait for a while */ + + return 0; +} diff --git a/sys/arch/luna88k/stand/boot/libsa.h b/sys/arch/luna88k/stand/boot/libsa.h index 9a3de988f1b..11168efb570 100644 --- a/sys/arch/luna88k/stand/boot/libsa.h +++ b/sys/arch/luna88k/stand/boot/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.2 2023/02/23 19:48:22 miod Exp $ */ +/* $OpenBSD: libsa.h,v 1.3 2023/03/13 11:59:39 aoyama Exp $ */ /* public domain */ @@ -7,3 +7,5 @@ void devboot(dev_t, char *); void machdep(void); void run_loadfile(uint64_t *, int); + +#define MACHINE_CMD cmd_machine /* we have luna88k-specific commands */