/*
 * Copyright (c) 2026, Chloe M.
 * Provided under the BSD-3 clause.
 *
 * Description: Program loader dispatch
 * Author:      Chloe M.
 */

#include <ex/loader.h>
#include <ex/elf64.h>

/* Loader dispatch table */
static LOADER_OPS *LoaderOpsTable[] = {
    [LOADER_ELF64] = &gElf64Ops
};

PT_STATUS
ExLoadProgramOf(LOADER_TYPE LoaderType, MMU_VAS *Vas, VOID *Data, LOADER_PROGRAM *Result)
{
    LOADER_OPS *Ops;

    if (Data == NULL || Result == NULL) {
        return STATUS_INVALID_PARAM;
    }

    if (LoaderType >= NELEM(LoaderOpsTable)) {
        return STATUS_NOT_FOUND;
    }

    Ops = LoaderOpsTable[LoaderType];
    return Ops->LoadProgram(Vas, Data, Result);
}
