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
use core::ptr;
const SN_1: u32 = 0x0080A00C;
const SN_2: u32 = 0x0080A040;
const SN_3: u32 = 0x0080A044;
const SN_4: u32 = 0x0080A048;
pub fn split_serial_number() -> (u32, u32, u32, u32) {
unsafe {
(
ptr::read(SN_1 as *const u32),
ptr::read(SN_2 as *const u32),
ptr::read(SN_3 as *const u32),
ptr::read(SN_4 as *const u32),
)
}
}
pub fn serial_number() -> [u8; 16] {
let sn = split_serial_number();
[
((sn.0 >> 24) & 0xff) as u8,
((sn.0 >> 16) & 0xff) as u8,
((sn.0 >> 8) & 0xff) as u8,
(sn.0 & 0xff) as u8,
((sn.1 >> 24) & 0xff) as u8,
((sn.1 >> 16) & 0xff) as u8,
((sn.1 >> 8) & 0xff) as u8,
(sn.1 & 0xff) as u8,
((sn.2 >> 24) & 0xff) as u8,
((sn.2 >> 16) & 0xff) as u8,
((sn.2 >> 8) & 0xff) as u8,
(sn.2 & 0xff) as u8,
((sn.3 >> 24) & 0xff) as u8,
((sn.3 >> 16) & 0xff) as u8,
((sn.3 >> 8) & 0xff) as u8,
(sn.3 & 0xff) as u8,
]
}