2 * Copyright (c) 2007-2010 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * The TOD hardware adds 1 to the 51st bit every microsecond
28 * The timer hardware subtracts 1 from the 51st bit every microsecond
30 #define CLK_MICROSEC 0x1000UL
31 #define CLK_SEC 0xf4240000ULL
32 #define CLK_MIN 0x3938700000ULL
33 #define CLK_HOUR 0xd693a400000ULL
34 #define CLK_DAY 0x141dd76000000ULL
35 #define CLK_YEAR 0x1cae8c13e000000ULL
36 #define CLK_FOURYEARS 0x72ce4e26e000000ULL
44 extern struct datetime
*parse_tod(struct datetime
*dt
, u64 tod
);
46 static inline int get_tod(u64
*tod
)
53 * STCKF was added to the z9, and therefore generates a
54 * operation exception on any pre-z9 hardware.
56 * GNU as doesn't like stckf mnemonic, so let's just invoke
59 ".insn s,0xb27c0000,%0\n"
76 static inline int get_parsed_tod(struct datetime
*dt
)
88 static inline int leap_year(int year
)
90 return (year
% 4 == 0) && (year
% 100 != 0 || year
% 400 == 0);