source: mainline/boot/arch/ia64/loader/gefi/lib/runtime/rtstr.c@ 36251c6

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 36251c6 was 7208b6c, checked in by Jakub Vana <jakub.vana@…>, 18 years ago

Basic IA64 boot and kernel suport for real machines

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*++
2
3Copyright (c) 1998 Intel Corporation
4
5Module Name:
6
7 str.c
8
9Abstract:
10
11 String runtime functions
12
13
14Revision History
15
16--*/
17
18#include "lib.h"
19
20#pragma RUNTIME_CODE(RtAcquireLock)
21INTN
22RUNTIMEFUNCTION
23RtStrCmp (
24 IN CHAR16 *s1,
25 IN CHAR16 *s2
26 )
27// compare strings
28{
29 while (*s1) {
30 if (*s1 != *s2) {
31 break;
32 }
33
34 s1 += 1;
35 s2 += 1;
36 }
37
38 return *s1 - *s2;
39}
40
41#pragma RUNTIME_CODE(RtStrCpy)
42VOID
43RUNTIMEFUNCTION
44RtStrCpy (
45 IN CHAR16 *Dest,
46 IN CHAR16 *Src
47 )
48// copy strings
49{
50 while (*Src) {
51 *(Dest++) = *(Src++);
52 }
53 *Dest = 0;
54}
55
56#pragma RUNTIME_CODE(RtStrCat)
57VOID
58RUNTIMEFUNCTION
59RtStrCat (
60 IN CHAR16 *Dest,
61 IN CHAR16 *Src
62 )
63{
64 RtStrCpy(Dest+StrLen(Dest), Src);
65}
66
67#pragma RUNTIME_CODE(RtStrLen)
68UINTN
69RUNTIMEFUNCTION
70RtStrLen (
71 IN CHAR16 *s1
72 )
73// string length
74{
75 UINTN len;
76
77 for (len=0; *s1; s1+=1, len+=1) ;
78 return len;
79}
80
81#pragma RUNTIME_CODE(RtStrSize)
82UINTN
83RUNTIMEFUNCTION
84RtStrSize (
85 IN CHAR16 *s1
86 )
87// string size
88{
89 UINTN len;
90
91 for (len=0; *s1; s1+=1, len+=1) ;
92 return (len + 1) * sizeof(CHAR16);
93}
94
95#pragma RUNTIME_CODE(RtBCDtoDecimal)
96UINT8
97RUNTIMEFUNCTION
98RtBCDtoDecimal(
99 IN UINT8 BcdValue
100 )
101{
102 UINTN High, Low;
103
104 High = BcdValue >> 4;
105 Low = BcdValue - (High << 4);
106
107 return ((UINT8)(Low + (High * 10)));
108}
109
110
111#pragma RUNTIME_CODE(RtDecimaltoBCD)
112UINT8
113RUNTIMEFUNCTION
114RtDecimaltoBCD (
115 IN UINT8 DecValue
116 )
117{
118 UINTN High, Low;
119
120 High = DecValue / 10;
121 Low = DecValue - (High * 10);
122
123 return ((UINT8)(Low + (High << 4)));
124}
125
126
Note: See TracBrowser for help on using the repository browser.