summaryrefslogtreecommitdiff
path: root/MdePkg/Library/ArmTransferListLib/TransferListLibSupport.h
blob: 7dc02a4aa9487148c502163cf3cfb38e69897596 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/** @file
  Root include file of C runtime library to support building the third-party
  Transfer List library.

  Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#pragma once

#include <Base.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>

//
// Standard C integer types mapping to UEFI types
//
typedef UINT8   uint8_t;
typedef UINT16  uint16_t;
typedef INT32   int32_t;
typedef UINT32  uint32_t;
typedef UINT64  uint64_t;
typedef UINTN   uintptr_t;
typedef UINTN   size_t;
typedef INTN    ptrdiff_t;
typedef INT64   intmax_t;
typedef UINT64  uintmax_t;

//
// Boolean type support
//
#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
/* bool, true and false are keywords.  */
#else
typedef BOOLEAN bool;
#define true   (1 == 1)
#define false  (1 == 0)
#endif

//
// Standard definitions
//
#ifndef NULL
#define NULL  ((void *)0)
#endif

//
// Definitions for global constants used by Transfer List library routines
//
#define INT_MAX     0x7FFFFFFF           /* Maximum (signed) int value */
#define INT32_MAX   0x7FFFFFFF           /* Maximum (signed) int32 value */
#define UINT32_MAX  0xFFFFFFFF           /* Maximum unsigned int32 value */

//
// Printf format specifiers from inttypes.h
//
#define PRIx32  "x"
#define PRIX32  "X"
#define PRId32  "d"
#define PRIu32  "u"
#define PRIx64  "llx"
#define PRIX64  "llX"
#define PRId64  "lld"
#define PRIu64  "llu"

//
// Function prototypes of Transfer List Library routines
//
void *
memset     (
  void *,
  int,
  size_t
  );

int
memcmp      (
  const void *,
  const void *,
  size_t
  );

void *
memcpy (
  void        *dest,
  const void  *source,
  size_t      count
  );

void *
memmove (
  void        *dest,
  const void  *source,
  size_t      count
  );

int
printf (
  const char  *format,
  ...
  );

int
vprintf (
  const char  *format,
  VA_LIST     args
  );

size_t
strlen (
  const char  *str
  );

char *
strcpy (
  char        *dest,
  const char  *src
  );

int
strcmp (
  const char  *str1,
  const char  *str2
  );

//
// Variable argument support - map to UEFI VA_LIST
//
typedef VA_LIST va_list;
#define va_start(ap, last)  VA_START(ap, last)
#define va_end(ap)          VA_END(ap)
#define va_arg(ap, type)    VA_ARG(ap, type)

//
// Macros that directly map functions to BaseLib, BaseMemoryLib functions
//
#define assert(expression)
#define memcpy(dest, source, count)   CopyMem(dest, source, (UINTN)(count))
#define memset(dest, ch, count)       SetMem(dest, (UINTN)(count), (UINT8)(ch))
#define memcmp(buf1, buf2, count)     (int)(CompareMem(buf1, buf2, (UINTN)(count)))
#define memmove(dest, source, count)  CopyMem(dest, source, (UINTN)(count))
#define printf(...)                   DebugPrint(DEBUG_INFO, __VA_ARGS__)
#define vprintf(format, args)         DebugVPrint(DEBUG_INFO, format, args)
#define strlen(str)                   (size_t)(AsciiStrLen(str))
#define strcpy(dest, src)             AsciiStrCpyS(dest, AsciiStrSize(src), src)
#define strcmp(str1, str2)            (int)(AsciiStrCmp(str1, str2))