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

#ifndef _EX_LOADER_H_
#define _EX_LOADER_H_ 1

#include <hal/mmu.h>
#include <ptapi/status.h>
#include <ptdef.h>

/*
 * Valid loader types that can be dispatched
 */
typedef enum {
    LOADER_ELF64
} LOADER_TYPE;

/*
 * Represents a loaded program that has been loaded
 * by a specific loader.
 *
 * @EntryPoint:  Entrypoint of program
 * @ProgramData: Loaded program data
 */
typedef struct {
    UPTR EntryPoint;
    VOID *ProgramData;
} LOADER_PROGRAM;

/*
 * Loader operations associated with a specific
 * loader.
 *
 * @LoadProgram:  Callback used to invoke the loader
 */
typedef struct {
    PT_STATUS(*LoadProgram)(MMU_VAS *Vas, VOID *Data, LOADER_PROGRAM *Result);
} LOADER_OPS;

/*
 * Load a specific program using a specific loader type
 *
 * @LoaderType:   Type of loader to invoke
 * @Vas:          Virtual address space to load in
 * @Data:         Program binary to load
 * @Result:       Loader program result is written here
 */
PT_STATUS ExLoadProgramOf(
    LOADER_TYPE LoaderType, MMU_VAS *Vas,
    VOID *Data, LOADER_PROGRAM *Result
);

#endif  /* !_EX_LOADER_H_ */
