<commit_before>#include "console.h"
#include "tinycstd.h"
#include "trap.h"


int main(int argc, char** argv);
void usermode_test();


void bootstrap() {
    uint64_t val = 0xF00DBEEF;

    console_init();

    write(1, "Setting up trap handlers...", 27);
    setup_smode_trap_handler(trap_handler_wrapper);
    enable_smode_interrupt_types((1 << CSR_SIE_TIMER_INTS) |
                                 (1 << CSR_SIE_SOFTWARE_INTS) |
                                 (1 << CSR_UIE_SOFTWARE_INTS));
    write(1, "done!\n", 6);

    char* args[] = {
        "./selfie",
        "-c",
        "selfie.c",
        "-m",
        "32",
        "-l",
        "selfie.m",
        "-y",
        "16",
        "-c",
        "hello-world.c",
        (char*)0,
    };
    int i = 0;

    write(1, "Booting selfie with args: ", 26);
    console_putc('\n');

    while (args[i] != (char*)0) {
        write(1, "    ", 4);
        write(1, args[i], strlen(args[i]));
        console_putc('\n');
        i++;
    }
    write(1, "    <END>\n", 10);
    console_putc('\n');

    asm volatile (
        "csrw sepc, %[umode];\n"
        "sret"
        :
        : [umode] "r" (usermode_test)
    );

    // i contains the count of command line arguments
    int exit = main(i, args);


    printf("\n\nFunction main terminated with exit code 0x%x", exit);
}

void usermode_test() {
    while (1) {
        asm volatile(
            "ecall"
        );
    }
}<commit_msg>load syscall ID in u-mode test function<commit_after>#include "console.h"
#include "tinycstd.h"
#include "trap.h"


int main(int argc, char** argv);
void usermode_test();


void bootstrap() {
    uint64_t val = 0xF00DBEEF;

    console_init();

    write(1, "Setting up trap handlers...", 27);
    setup_smode_trap_handler(trap_handler_wrapper);
    enable_smode_interrupt_types((1 << CSR_SIE_TIMER_INTS) |
                                 (1 << CSR_SIE_SOFTWARE_INTS) |
                                 (1 << CSR_UIE_SOFTWARE_INTS));
    write(1, "done!\n", 6);

    char* args[] = {
        "./selfie",
        "-c",
        "selfie.c",
        "-m",
        "32",
        "-l",
        "selfie.m",
        "-y",
        "16",
        "-c",
        "hello-world.c",
        (char*)0,
    };
    int i = 0;

    write(1, "Booting selfie with args: ", 26);
    console_putc('\n');

    while (args[i] != (char*)0) {
        write(1, "    ", 4);
        write(1, args[i], strlen(args[i]));
        console_putc('\n');
        i++;
    }
    write(1, "    <END>\n", 10);
    console_putc('\n');

    asm volatile (
        "csrw sepc, %[umode];\n"
        "sret"
        :
        : [umode] "r" (usermode_test)
    );

    // i contains the count of command line arguments
    int exit = main(i, args);


    printf("\n\nFunction main terminated with exit code 0x%x", exit);
}

void usermode_test() {
    while (1) {
        asm volatile(
            "li a7, 0x101;"
            "ecall"
        );
    }
}
{'fraction_non_alphanumeric': 0.16903794037940378, 'fraction_numerical': 0.022696476964769646, 'mean_word_length': 1.7418755803156918, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2091875', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1066, 'n_words': 227}