OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
modelinfo.h
Go to the documentation of this file.
1//
2// Decode mac serial number
3//
4// Copyright (c) 2018 vit9696
5//
6
7#ifndef GENSERIAL_MODELINFO_H
8#define GENSERIAL_MODELINFO_H
9
10#include <assert.h>
11
12#include "macserial.h"
13#include "modelinfo_autogen.h"
14
15#ifdef static_assert
16static_assert(ARRAY_SIZE(AppleModelCode) == APPLE_MODEL_MAX &&
17 ARRAY_SIZE(AppleBoardCode) == APPLE_MODEL_MAX &&
18 ARRAY_SIZE(ApplePlatformData) == APPLE_MODEL_MAX &&
19 ARRAY_SIZE(AppleModelYear) == APPLE_MODEL_MAX &&
20 ARRAY_SIZE(ApplePreferredModelYear) == APPLE_MODEL_MAX,
21 "Inconsistent model data");
22#endif
23
24static const char *AppleLegacyLocations[] = {
25 "CK",
26 "CY",
27 "FC",
28 "G8",
29 "QP",
30 "XA",
31 "XB",
32 "PT",
33 "QT",
34 "UV",
35 "RN",
36 "RM",
37 "SG",
38 "W8",
39 "YM",
40 // New
41 "H0",
42 "C0",
43 "C3",
44 "C7",
45 "MB",
46 "EE",
47 "VM",
48 "1C",
49 "4H",
50 "MQ",
51 "WQ",
52 "7J",
53 "FK",
54 "F1",
55 "F2",
56 "F7",
57 "DL",
58 "DM",
59 "73",
60};
61
62#define APPLE_LEGACY_LOCATION_OLDMAX 15
63
64static const char *AppleLegacyLocationNames[] = {
65 "Ireland (Cork)",
66 "Korea",
67 "USA (Fountain, Colorado)",
68 "USA",
69 "USA",
70 "USA (ElkGrove/Sacramento, California)",
71 "USA (ElkGrove/Sacramento, California)",
72 "Korea",
73 "Taiwan (Quanta Computer)",
74 "Taiwan",
75 "Mexico",
76 "Refurbished Model",
77 "Singapore",
78 "China (Shanghai)",
79 "China",
80 // New
81 "Unknown",
82 "China (Quanta Computer, Tech-Com)",
83 "China (Shenzhen, Foxconn)",
84 "China (Shanghai, Pegatron)",
85 "Malaysia",
86 "Taiwan",
87 "Czech Republic (Pardubice, Foxconn)",
88 "China",
89 "China",
90 "China",
91 "China",
92 "China (Hon Hai/Foxconn)",
93 "China (Zhengzhou, Foxconn)",
94 "China (Zhengzhou, Foxconn)",
95 "China (Zhengzhou, Foxconn)",
96 "China",
97 "China (Foxconn)",
98 "China (Foxconn)",
99 "Unknown",
100};
101
102static const char *AppleLocations[] = {
103 "C02",
104 "C07",
105 "C17",
106 "C1M",
107 "C2V",
108 "CK2",
109 "D25",
110 "F5K",
111 "W80",
112 "W88",
113 "W89",
114 "CMV",
115 "YM0",
116 "DGK",
117 "FVF"
118};
119
120static const char *AppleLocationNames[] = {
121 "China (Quanta Computer)",
122 "China (Quanta Computer)",
123 "China",
124 "China",
125 "China",
126 "Ireland (Cork)",
127 "Unknown",
128 "USA (Flextronics)",
129 "Unknown",
130 "Unknown",
131 "Unknown",
132 "Unknown",
133 "China (Hon Hai/Foxconn)",
134 "Unknown",
135 "Unknown"
136};
137
138#ifdef static_assert
139static_assert(ARRAY_SIZE(AppleLegacyLocations) == ARRAY_SIZE(AppleLegacyLocationNames),
140 "Inconsistent legacy location data");
141static_assert(ARRAY_SIZE(AppleLocations) == ARRAY_SIZE(AppleLocationNames),
142 "Inconsistent legacy location data");
143#endif
144
145static const char *MLBBlock1[] = {
146 "200", "600", "403", "404", "405", "303", "108",
147 "207", "609", "501", "306", "102", "701", "301",
148 "501", "101", "300", "130", "100", "270", "310",
149 "902", "104", "401", "902", "500", "700", "802"
150};
151
152static const char *MLBBlock2[] = {
153 "GU", "4N", "J9", "QX", "OP", "CD", "GU"
154};
155
156static const char *MLBBlock3[] = {
157 "1H", "1M", "AD", "1F", "A8", "UE", "JA", "JC", "8C", "CB", "FB"
158};
159
160// Used for line/copy: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
161static int32_t AppleTblBase34[] = {10, 11, 12, 13, 14, 15, 16, 17, 0, 18, 19, 20, 21, 22, 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33};
162static const char *AppleBase34Blacklist = "IO";
163static const char *AppleBase34Reverse = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
164
165// Used for year: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
166static int32_t AppleTblYear[] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 2, 3, 3, 4, 4, 0, 5, 5, 6, 6, 7, 0, 7, 8, 8, 9, 9};
167static const char *AppleYearBlacklist = "ABEIOU";
168static const char *AppleYearReverse = "CDFGHJKLMNPQRSTVWXYZ";
169
170// Used for week to year add: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
171static int32_t AppleTblWeekAdd[] = { 0, 0, 0, 26, 0, 0, 26, 0, 0, 26, 0, 26, 0, 26, 0, 0, 26, 0, 26, 0, 0, 26, 0, 26, 0, 26};
172
173// Used for week A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
174static int32_t AppleTblWeek[] = { 0, 0, 10, 11, 0, 12, 13, 14, 0, 15, 16, 17, 18, 19, 0, 20, 21, 22, 0, 23, 0, 24, 25, 26, 27, 0};
175static const char *AppleWeekBlacklist = "ABEIOSUZ";
176static const char *AppleWeekReverse = "0123456789CDFGHJKLMNPQRTVWX123456789CDFGHJKLMNPQRTVWXY";
177
178#ifdef static_assert
179static_assert(ARRAY_SIZE(AppleTblBase34) == 26 && ARRAY_SIZE(AppleTblYear) == 26 &&
180 ARRAY_SIZE(AppleTblWeekAdd) == 26 && ARRAY_SIZE(AppleTblWeek) == 26,
181 "Conversion table must cover latin alphabet");
182#endif
183
184#endif // GENSERIAL_MODELINFO_H
#define ARRAY_SIZE(Array)
Definition AppleMacEfi.h:34
INT32 int32_t
Definition lzss.h:34
#define APPLE_MODEL_MAX