summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/FirmwareKit/Handover.h
blob: 4128db2c7b43cc8db4772b221063ae51cda33bcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel

#ifndef FIRMWAREKIT_HANDOVER_H
#define FIRMWAREKIT_HANDOVER_H

#include <FirmwareKit/EFI/EFI.h>
#include <NeKit/Config.h>

#define kHandoverMagic (0xBADCC)
#define kHandoverVersion (0x0117)

/* Initial bitmap pointer location and size. */
#define kHandoverStructSz sizeof(HEL::BootInfoHeader)

namespace Kernel::HEL {
/**
@brief The executable type enum.
*/
enum {
  kTypeKernel       = 100,
  kTypeKernelDriver = 101,
  kTypeRsrc         = 102,
  kTypeInvalid      = 103,
  kTypeCount        = 4,
};

/**
@brief The executable architecture enum.
*/

enum {
  kArchAMD64 = 122,
  kArchARM64 = 123,
  kArchRISCV = 124,
  kArchCount = 3,
};

struct BootInfoHeader final {
  UInt64 f_Magic;
  UInt64 f_Version;

  VoidPtr f_BitMapStart;
  SizeT   f_BitMapSize;

  VoidPtr f_PageStart;

  VoidPtr f_KernelImage;
  SizeT   f_KernelSz;

  VoidPtr f_LibSystemImage;
  SizeT   f_LibSystemSz;

  VoidPtr f_StackTop;
  SizeT   f_StackSz;

  WideChar f_FirmwareVendorName[32];
  SizeT    f_FirmwareVendorLen;

  VoidPtr f_FirmwareCustomTables[2];  // On EFI 0: BS 1: ST

  struct {
    VoidPtr      f_SmBios;
    VoidPtr      f_VendorPtr;
    VoidPtr      f_MpPtr;
    Bool         f_MultiProcessingEnabled;
    UInt32       f_ImageKey;
    EfiHandlePtr f_ImageHandle;
  } f_HardwareTables;

  struct {
    UIntPtr f_The;
    SizeT   f_Size;
    UInt32  f_Width;
    UInt32  f_Height;
    UInt32  f_PixelFormat;
    UInt32  f_PixelPerLine;
  } f_GOP;

  UInt64 f_FirmwareSpecific[8];
};

enum {
  kHandoverTableBS,
  kHandoverTableST,
  kHandoverTableCount,
};

/// @brief Alias of bootloader main type.
typedef Int32 (*HandoverProc)(BootInfoHeader* boot_info);
}  // namespace Kernel::HEL

/// @brief Bootloader information header global variable.
inline Kernel::HEL::BootInfoHeader* kHandoverHeader = nullptr;

#endif