<commit_before>/* $chaos: exception.c,v 1.2 2002/06/11 21:26:50 per Exp $ */
/* Abstract: Exception handling. */
/* Author: <NAME> <<EMAIL>> */

/* Copyright 2002 chaos development. */
/* Use freely under the terms listed in the file COPYING. */

#include <storm/ia32/cpu.h>
#include <storm/ia32/debug.h>
#include <storm/ia32/defines.h>
#include <storm/ia32/exception.h>
#include <storm/ia32/gdt.h>
#include <storm/ia32/idt.h>

/* One function for each exception. */
static void exception_divide_error_fault (void)
{
    debug_print ("Divide error fault.\n");
    while (TRUE);
}

static void exception_debug_trap (void)
{
    debug_print ("Debug trap.\n");
    while (TRUE);
}

static void exception_nmi (void)
{
    debug_print ("NMI.\n");
    while (TRUE);
}

static void exception_breakpoint_trap (void)
{
    debug_print ("Breakpoint trap.\n");
    while (TRUE);
}

static void exception_overflow_trap (void)
{
    debug_print ("Overflow trap.\n");
    while (TRUE);
}

static void exception_bound_range_exceeded_fault (void)
{
    debug_print ("Bound range exceeded fault.\n");
    while (TRUE);
}

static void exception_invalid_opcode_fault (void)
{
    debug_print ("Invalid opcode fault.\n");
    while (TRUE);
}

static void exception_device_not_available_fault (void)
{
    debug_print ("Device not available fault.\n");
    while (TRUE);
}

static void exception_double_fault (void)
{
    debug_print ("Double fault.\n");
    while (TRUE);
}

static void exception_coprocessor_segment_overrun_abort (void)
{
    debug_print ("Coprocessor segment overrun abort.\n");
    while (TRUE);
}

static void exception_invalid_tss_fault (void)
{
    debug_print ("Invalid TSS fault.\n");
    while (TRUE);
}

static void exception_segment_not_present_fault (void)
{
    debug_print ("Segment not present fault.\n");
    while (TRUE);
}

static void exception_stack_fault (void)
{
    debug_print ("Stack fault.\n");
    while (TRUE);
}

static void exception_general_protection_fault (void)
{
    debug_print ("General protection fault.\n");
    while (TRUE);
}

static void exception_page_fault (void)
{
    debug_print ("Page fault at %x.\n", cpu_get_cr2());
    while (TRUE);
}  

static void exception_floating_point_error_fault (void)
{
    debug_print ("Floating point error fault.\n");
    while (TRUE);
}

static void exception_alignment_check_fault (void)
{
    debug_print ("Exception alignment check fault.\n");
    while (TRUE);
}

static void exception_machine_check_abort (void)
{
    debug_print ("Machine check abort.\n");
    while (TRUE);
}
<commit_msg>Started writing code for saving and dumping registers.<commit_after>/* $chaos: exception.c,v 1.3 2002/06/12 20:40:01 per Exp $ */
/* Abstract: Exception handling. */
/* Author: <NAME> <<EMAIL>> */

/* Copyright 2002 chaos development. */
/* Use freely under the terms listed in the file COPYING. */

#include <storm/ia32/cpu.h>
#include <storm/ia32/debug.h>
#include <storm/ia32/defines.h>
#include <storm/ia32/exception.h>
#include <storm/ia32/gdt.h>
#include <storm/ia32/idt.h>

/* Register values, saved on exception entry. */
cpu_register_t registers;

static inline void save_registers (void)
{
    asm volatile ("movl %%eax, registers + 0\n"
                  "movl %%ebx, registers + 4\n"
                  "movl %%ecx, registers + 8\n"
                  "movl %%edx, registers + 12\n"
                  "movl %%esi, registers + 16\n"
                  "movl %%edi, registers + 20\n"
                  :
                  :
                  :
                  "memory");
}

/* One function for each exception. */
static void exception_divide_error_fault (void)
{
    debug_print ("Divide error fault.\n");
    while (TRUE);
}

static void exception_debug_trap (void)
{
    debug_print ("Debug trap.\n");
    while (TRUE);
}

static void exception_nmi (void)
{
    debug_print ("NMI.\n");
    while (TRUE);
}

static void exception_breakpoint_trap (void)
{
    debug_print ("Breakpoint trap.\n");
    while (TRUE);
}

static void exception_overflow_trap (void)
{
    debug_print ("Overflow trap.\n");
    while (TRUE);
}

static void exception_bound_range_exceeded_fault (void)
{
    debug_print ("Bound range exceeded fault.\n");
    while (TRUE);
}

static void exception_invalid_opcode_fault (void)
{
    debug_print ("Invalid opcode fault.\n");
    while (TRUE);
}

static void exception_device_not_available_fault (void)
{
    debug_print ("Device not available fault.\n");
    while (TRUE);
}

static void exception_double_fault (void)
{
    debug_print ("Double fault.\n");
    while (TRUE);
}

static void exception_coprocessor_segment_overrun_abort (void)
{
    debug_print ("Coprocessor segment overrun abort.\n");
    while (TRUE);
}

static void exception_invalid_tss_fault (void)
{
    debug_print ("Invalid TSS fault.\n");
    while (TRUE);
}

static void exception_segment_not_present_fault (void)
{
    debug_print ("Segment not present fault.\n");
    while (TRUE);
}

static void exception_stack_fault (void)
{
    debug_print ("Stack fault.\n");
    while (TRUE);
}

static void exception_general_protection_fault (void)
{
    debug_print ("General protection fault.\n");
    while (TRUE);
}

static void exception_page_fault (void)
{
    save_registers ();
    debug_print ("Page fault at %x.\n", cpu_get_cr2());
    debug_print ("EAX: %x EBX: %x ECX: %x EDX: %x\n", registers.eax,
                 registers.ebx, registers.ecx, registers.edx);
    debug_print ("ESI: %x EDI: %x", registers.esi, 
                 registers.edi);
    while (TRUE);
}  

static void exception_floating_point_error_fault (void)
{
    debug_print ("Floating point error fault.\n");
    while (TRUE);
}

static void exception_alignment_check_fault (void)
{
    debug_print ("Exception alignment check fault.\n");
    while (TRUE);
}

static void exception_machine_check_abort (void)
{
    debug_print ("Machine check abort.\n");
    while (TRUE);
}

{'fraction_non_alphanumeric': 0.131894079946028, 'fraction_numerical': 0.0126496879743633, 'mean_word_length': 3.415487714072971, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '222967', 'n_tokens_mistral': 2030, 'n_tokens_neox': 1929, 'n_words': 520}