<commit_before>/**
 * @file
 *
 * @date 10.11.10
 * @author <NAME>
 */

#include <hal/arch.h>
#include <asm/traps.h>
#include <hal/ipl.h>
#include <asm/io.h>

void arch_init(void) {
	gdt_init();
	idt_init();
}

void arch_idle(void) {
	__asm__ __volatile__("hlt");
}

#if 1
//http://mjg59.dreamwidth.org/3561.html
//http://stackoverflow.com/questions/3145569/how-to-power-down-the-computer-from-a-freestanding-environment
void arch_reset_kbd(void) {
	while (in8(0x64) & 0x2);
	out8(0x60, 0x64);
	while (in8(0x64) & 0x2);
	out8(0x4, 0x60);
	while (in8(0x64) & 0x2);
	out8(0xfe, 0x64);
}
#endif


extern void cpu_reset(void);
extern void acpi_power_off(void);
void __attribute__ ((noreturn)) arch_shutdown(arch_shutdown_mode_t mode) {
	cpu_reset();

//	acpi_power_off();

	//outw(0xB004, 0x0 | 0x2000);
	//asm("cli;hlt");

	while (1) {}
}



#if 0
	cli
	movl	$null_idt, %eax		/* Reset by triple fault */
	lidt	(%eax)<commit_msg>Remove reset from arch_shutdown in x86 architecture<commit_after>/**
 * @file
 *
 * @date 10.11.10
 * @author <NAME>
 */

#include <hal/arch.h>
#include <asm/traps.h>
#include <hal/ipl.h>
#include <asm/io.h>

void arch_init(void) {
	gdt_init();
	idt_init();
}

void arch_idle(void) {
	__asm__ __volatile__("hlt");
}

#if 1
//http://mjg59.dreamwidth.org/3561.html
//http://stackoverflow.com/questions/3145569/how-to-power-down-the-computer-from-a-freestanding-environment
void arch_reset_kbd(void) {
	while (in8(0x64) & 0x2);
	out8(0x60, 0x64);
	while (in8(0x64) & 0x2);
	out8(0x4, 0x60);
	while (in8(0x64) & 0x2);
	out8(0xfe, 0x64);
}
#endif


extern void cpu_reset(void);
extern void acpi_power_off(void);
void __attribute__ ((noreturn)) arch_shutdown(arch_shutdown_mode_t mode) {
//	cpu_reset();

//	acpi_power_off();

	//outw(0xB004, 0x0 | 0x2000);
	//asm("cli;hlt");

	while (1) {}
}



#if 0
	cli
	movl	$null_idt, %eax		/* Reset by triple fault */
	lidt	(%eax)
{'fraction_non_alphanumeric': 0.18412698412698414, 'fraction_numerical': 0.07407407407407407, 'mean_word_length': 4.296918767507003, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4523355', 'n_tokens_mistral': 963, 'n_tokens_neox': 866, 'n_words': 155}