From ad24b764d654c36b40ad2099d08d95bff9856cdd Mon Sep 17 00:00:00 2001 From: Matheus Pecoraro Date: Mon, 3 Jun 2024 15:45:29 -0300 Subject: [PATCH] amd64: Add bsp_reset Add a temporary implementation of bsp_reset using the keyboard controller until the ACPI method can be implemented --- bsps/x86_64/amd64/start/bspreset.c | 37 ++++++++++++++++++++ spec/build/bsps/x86_64/amd64/bspamd64.yml | 2 +- spec/build/bsps/x86_64/amd64/bspamd64efi.yml | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 bsps/x86_64/amd64/start/bspreset.c diff --git a/bsps/x86_64/amd64/start/bspreset.c b/bsps/x86_64/amd64/start/bspreset.c new file mode 100644 index 0000000000..9402345242 --- /dev/null +++ b/bsps/x86_64/amd64/start/bspreset.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * Copyright (C) 2024 Matheus Pecoraro + * + * 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 + +#define KEYBOARD_CONTROLLER_PORT 0x64 +#define PULSE_RESET_LINE 0xFE + +/* TODO: Update this method once APICA is implemented */ +void bsp_reset(void) +{ + outport_byte(KEYBOARD_CONTROLLER_PORT, PULSE_RESET_LINE); +} diff --git a/spec/build/bsps/x86_64/amd64/bspamd64.yml b/spec/build/bsps/x86_64/amd64/bspamd64.yml index c05c0bc4ff..b07687b7a0 100644 --- a/spec/build/bsps/x86_64/amd64/bspamd64.yml +++ b/spec/build/bsps/x86_64/amd64/bspamd64.yml @@ -45,7 +45,6 @@ source: - bsps/shared/dev/serial/console-termios.c - bsps/shared/irq/irq-default-handler.c - bsps/shared/start/bspfatal-default.c -- bsps/shared/start/bspreset-empty.c - bsps/shared/start/gettargethash-default.c - bsps/shared/start/sbrk.c - bsps/x86_64/amd64/clock/clock.c @@ -54,5 +53,6 @@ source: - bsps/x86_64/amd64/interrupts/isr_handler.S - bsps/x86_64/amd64/interrupts/pic.c - bsps/x86_64/amd64/start/bspstart.c +- bsps/x86_64/amd64/start/bspreset.c - bsps/x86_64/amd64/start/page.c type: build diff --git a/spec/build/bsps/x86_64/amd64/bspamd64efi.yml b/spec/build/bsps/x86_64/amd64/bspamd64efi.yml index e822252002..9dfefc4b59 100644 --- a/spec/build/bsps/x86_64/amd64/bspamd64efi.yml +++ b/spec/build/bsps/x86_64/amd64/bspamd64efi.yml @@ -65,7 +65,6 @@ source: - bsps/shared/dev/serial/console-termios.c - bsps/shared/irq/irq-default-handler.c - bsps/shared/start/bspfatal-default.c -- bsps/shared/start/bspreset-empty.c - bsps/shared/start/gettargethash-default.c - bsps/shared/start/sbrk.c - bsps/x86_64/amd64/clock/eficlock.c @@ -78,6 +77,7 @@ source: - bsps/x86_64/amd64/interrupts/isr_handler.S - bsps/x86_64/amd64/interrupts/pic.c - bsps/x86_64/amd64/start/bspstart.c +- bsps/x86_64/amd64/start/bspreset.c - bsps/x86_64/amd64/start/multiboot2.c - bsps/x86_64/amd64/start/efimem.c - bsps/x86_64/amd64/start/page.c