• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*++
2 
3 Copyright (c) 1999  Intel Corporation
4 
5 Module Name:
6 
7     EfiRtLib.h
8 
9 Abstract:
10 
11     EFI Runtime library functions
12 
13 
14 
15 Revision History
16 
17 --*/
18 
19 #include "efi.h"
20 #include "efilib.h"
21 #include "efirtlib.h"
22 
23 #ifndef __GNUC__
24 #pragma RUNTIME_CODE(RtZeroMem)
25 #endif
26 VOID
27 RUNTIMEFUNCTION
RtZeroMem(IN VOID * Buffer,IN UINTN Size)28 RtZeroMem (
29     IN VOID     *Buffer,
30     IN UINTN     Size
31     )
32 {
33     INT8        *pt;
34 
35     pt = Buffer;
36     while (Size--) {
37         *(pt++) = 0;
38     }
39 }
40 
41 #ifndef __GNUC__
42 #pragma RUNTIME_CODE(RtSetMem)
43 #endif
44 VOID
45 RUNTIMEFUNCTION
RtSetMem(IN VOID * Buffer,IN UINTN Size,IN UINT8 Value)46 RtSetMem (
47     IN VOID     *Buffer,
48     IN UINTN    Size,
49     IN UINT8    Value
50     )
51 {
52     INT8        *pt;
53 
54     pt = Buffer;
55     while (Size--) {
56         *(pt++) = Value;
57     }
58 }
59 
60 #ifndef __GNUC__
61 #pragma RUNTIME_CODE(RtCopyMem)
62 #endif
63 VOID
64 RUNTIMEFUNCTION
RtCopyMem(IN VOID * Dest,IN CONST VOID * Src,IN UINTN len)65 RtCopyMem (
66     IN VOID     *Dest,
67     IN CONST VOID     *Src,
68     IN UINTN    len
69     )
70 {
71     CHAR8   *d;
72     CONST CHAR8 *s = Src;
73     d = Dest;
74     while (len--) {
75         *(d++) = *(s++);
76     }
77 }
78 
79 #ifndef __GNUC__
80 #pragma RUNTIME_CODE(RtCompareMem)
81 #endif
82 INTN
83 RUNTIMEFUNCTION
RtCompareMem(IN CONST VOID * Dest,IN CONST VOID * Src,IN UINTN len)84 RtCompareMem (
85     IN CONST VOID     *Dest,
86     IN CONST VOID     *Src,
87     IN UINTN    len
88     )
89 {
90     CONST CHAR8    *d = Dest, *s = Src;
91     while (len--) {
92         if (*d != *s) {
93             return *d - *s;
94         }
95 
96         d += 1;
97         s += 1;
98     }
99 
100     return 0;
101 }
102 
103 #ifndef __GNUC__
104 #pragma RUNTIME_CODE(RtCompareGuid)
105 #endif
106 INTN
107 RUNTIMEFUNCTION
RtCompareGuid(IN EFI_GUID * Guid1,IN EFI_GUID * Guid2)108 RtCompareGuid (
109     IN EFI_GUID     *Guid1,
110     IN EFI_GUID     *Guid2
111     )
112 /*++
113 
114 Routine Description:
115 
116     Compares to GUIDs
117 
118 Arguments:
119 
120     Guid1       - guid to compare
121     Guid2       - guid to compare
122 
123 Returns:
124     = 0     if Guid1 == Guid2
125 
126 --*/
127 {
128     INT32       *g1, *g2, r;
129 
130     //
131     // Compare 32 bits at a time
132     //
133 
134     g1 = (INT32 *) Guid1;
135     g2 = (INT32 *) Guid2;
136 
137     r  = g1[0] - g2[0];
138     r |= g1[1] - g2[1];
139     r |= g1[2] - g2[2];
140     r |= g1[3] - g2[3];
141 
142     return r;
143 }
144 
145 
146