xref: /haiku/headers/private/system/arch/ppc/arch_real_time_data.h (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef _KERNEL_ARCH_REAL_TIME_DATA_H
6 #define _KERNEL_ARCH_REAL_TIME_DATA_H
7 
8 #include <StorageDefs.h>
9 #include <SupportDefs.h>
10 
11 
12 struct ppc_real_time_data {
13 	vint64	system_time_offset;
14 };
15 
16 struct arch_real_time_data {
17 	struct ppc_real_time_data	data[2];
18 	vint32						system_time_conversion_factor;
19 	vint32						version;
20 		// Since there're no cheap atomic_{set,get,add}64() on PPC 32 (i.e. one
21 		// that doesn't involve a syscall), we can't have just a single
22 		// system_time_offset and set/get it atomically.
23 		// That's why have our data twice. One set is current (indexed by
24 		// version % 2). When setting the offset, we do that with disabled
25 		// interrupts and protected by a spinlock. We write the new values
26 		// into the other array element and increment the version.
27 		// A reader first reads the version, then the date of interest, and
28 		// finally rechecks the version. If it hasn't changed in the meantime,
29 		// the read value is fine, otherwise it runs the whole procedure again.
30 		//
31 		// system_time_conversion_factor is currently consider constant,
32 		// although that is not necessarily true. We simply don't support
33 		// changing conversion factors at the moment.
34 };
35 
36 #endif	/* _KERNEL_ARCH_REAL_TIME_DATA_H */
37