memtest86plus/system/hwctrl.c

55 lines
1.1 KiB
C
Raw Normal View History

2020-05-24 15:30:55 -05:00
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2020 Martin Whitaker.
//
// Derived from an extract of memtest86+ lib.c:
//
// lib.c - MemTest-86 Version 3.4
//
// Released under version 2 of the Gnu Public License.
// By Chris Brady
#include <stdint.h>
#include "io.h"
#include "hwctrl.h"
2022-03-08 16:24:25 -06:00
#include "unistd.h"
2020-05-24 15:30:55 -05:00
//------------------------------------------------------------------------------
// Public Functions
//------------------------------------------------------------------------------
void reboot(void)
{
// Tell the BIOS to do a warm reboot.
*((uint16_t *)0x472) = 0x1234;
// Pulse the system reset signal.
outb(0xfe, 0x64);
2022-03-08 16:24:25 -06:00
// If not working, use cf9 method after 100ms delay
2022-03-08 16:30:31 -06:00
usleep(100000);
uint8_t cf9 = inb(0xcf9) & ~6;
outb(cf9|2, 0xcf9); /* Request hard reset */
usleep(50);
outb(cf9|6, 0xcf9); /* Actually do the reset */
usleep(50);
2022-03-08 16:24:25 -06:00
2020-05-24 15:30:55 -05:00
}
void floppy_off()
{
// Stop the floppy motor.
outb(0x8, 0x3f2);
}
void cursor_off()
{
// Set HW cursor off screen.
outb(0x0f, 0x3d4);
outb(0xff, 0x3d5);
outb(0x0e, 0x3d4);
outb(0xff, 0x3d5);
}