xref: /haiku/src/system/kernel/arch/generic/debug_uart.cpp (revision 6f80a9801fedbe7355c4360bd204ba746ec3ec2d)
1 /*
2  * Copyright 2006-2022, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <arch/generic/debug_uart.h>
8 
9 
10 void
11 DebugUART::Out8(int reg, uint8 value)
12 {
13 #if defined(__ARM__) || defined(__aarch64__)
14 	// 32-bit aligned
15 	*((uint8 *)Base() + reg * sizeof(uint32)) = value;
16 #else
17 	*((uint8 *)Base() + reg) = value;
18 #endif
19 }
20 
21 
22 uint8
23 DebugUART::In8(int reg)
24 {
25 #if defined(__ARM__) || defined(__aarch64__)
26 	// 32-bit aligned
27 	return *((uint8 *)Base() + reg * sizeof(uint32));
28 #else
29 	return *((uint8 *)Base() + reg);
30 #endif
31 }
32 
33 
34 void
35 DebugUART::Barrier()
36 {
37 	// Simple memory barriers
38 #if defined(__POWERPC__)
39 	asm volatile("eieio; sync");
40 #elif defined(__ARM__) || defined(__aarch64__)
41 	asm volatile ("" : : : "memory");
42 #endif
43 }
44