FreeNOS
ARMControl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "ARMCore.h"
19 #include "ARMControl.h"
20 
22 {
23 }
24 
26 {
27 }
28 
30 {
31  switch (reg)
32  {
33  case MainID: return mrc(p15, 0, 0, c0, c0);
34  case CoreID: return mrc(p15, 0, 5, c0, c0);
35  case SystemControl: return mrc(p15, 0, 0, c1, c0);
36  case AuxControl: return mrc(p15, 0, 1, c1, c0);
37  case TranslationTable0: return mrc(p15, 0, 0, c2, c0);
38  case TranslationTable1: return mrc(p15, 0, 1, c2, c0);
39  case TranslationTableCtrl: return mrc(p15, 0, 2, c2, c0);
40  case DomainControl: return mrc(p15, 0, 0, c3, c0);
41  case UserProcID: return mrc(p15, 0, 4, c13, c0);
42  case InstructionFaultAddress: return mrc(p15, 0, 2, c6, c0);
43  case InstructionFaultStatus: return mrc(p15, 0, 1, c5, c0);
44  case DataFaultAddress: return mrc(p15, 0, 0, c6, c0);
45  case DataFaultStatus: return mrc(p15, 0, 0, c5, c0);
46  case SystemFrequency: return mrc(p15, 0, 0, c14, c0);
47  default: break;
48  }
49  return 0;
50 }
51 
52 void ARMControl::write(Register reg, u32 value)
53 {
54  switch (reg)
55  {
56  case SystemControl: mcr(p15, 0, 0, c1, c0, value); break;
57  case AuxControl: mcr(p15, 0, 1, c1, c0, value); break;
58  case TranslationTable0: mcr(p15, 0, 0, c2, c0, value); break;
59  case TranslationTable1: mcr(p15, 0, 1, c2, c0, value); break;
60  case TranslationTableCtrl: mcr(p15, 0, 2, c2, c0, value); break;
61  case DomainControl: mcr(p15, 0, 0, c3, c0, value); break;
62  case CacheClear: mcr(p15, 0, 0, c7, c7, value); break;
63  case DataCacheClean: mcr(p15, 0, 0, c7, c14, value); break;
65  case InstructionCacheClear: mcr(p15, 0, 0, c7, c5, value); break;
66  case InstructionTLBClear: mcr(p15, 0, 0, c8, c5, value); break;
67  case DataTLBClear: mcr(p15, 0, 0, c8, c6, value); break;
68  case UnifiedTLBClear: mcr(p15, 0, 0, c8, c7, value); break;
69  case UserProcID: mcr(p15, 0, 4, c13, c0, value); break;
70  default: break;
71  }
72 }
73 
75 {
76  u32 val = read(reg);
77  val |= flags;
78  write(reg, val);
79 }
80 
82 {
83  u32 val = read(reg);
84  val &= ~(flags);
85  write(reg, val);
86 }
87 
89 {
91 }
92 
94 {
96 }
97 
99 {
100  set(AuxControl, flags);
101 }
102 
104 {
106 }
ARMControl::FlushPrefetchBuffer
@ FlushPrefetchBuffer
Definition: ARMControl.h:66
ARMControl::Register
Register
System Control Registers.
Definition: ARMControl.h:54
mrc
#define mrc(coproc, opcode1, opcode2, reg, subReg)
Move to ARM from CoProcessor (MRC).
Definition: ARMCore.h:51
ARMControl::InstructionTLBClear
@ InstructionTLBClear
Definition: ARMControl.h:68
ARMControl::unset
void unset(SystemControlFlags flags)
Unset system control flags in CP15.
Definition: ARMControl.cpp:93
ARMControl::DataFaultAddress
@ DataFaultAddress
Definition: ARMControl.h:74
ARMControl::write
void write(Register reg, u32 value)
Write register to the CP15.
Definition: ARMControl.cpp:52
mcr
#define mcr(coproc, opcode1, opcode2, reg, subReg, value)
Move to CoProcessor from ARM (MCR).
Definition: ARMCore.h:63
ARMControl::DomainControlFlags
DomainControlFlags
Domain Control flags.
Definition: ARMControl.h:111
flags
u32 flags
Definition: IntelACPI.h:66
ARMControl::AuxControlFlags
AuxControlFlags
Aux Control flags.
Definition: ARMControl.h:102
ARMControl::TranslationTableCtrl
@ TranslationTableCtrl
Definition: ARMControl.h:63
flushPrefetchBuffer
void flushPrefetchBuffer()
Flush Prefetch Buffer.
Definition: ARMCore.h:230
ARMControl::ARMControl
ARMControl()
Constructor.
Definition: ARMControl.cpp:21
ARMCore.h
ARMControl::DataTLBClear
@ DataTLBClear
Definition: ARMControl.h:69
ARMControl::InstructionFaultAddress
@ InstructionFaultAddress
Definition: ARMControl.h:72
ARMControl::~ARMControl
virtual ~ARMControl()
Destructor.
Definition: ARMControl.cpp:25
ARMControl::MainID
@ MainID
Definition: ARMControl.h:56
ARMControl::CoreID
@ CoreID
Definition: ARMControl.h:57
ARMControl::InstructionFaultStatus
@ InstructionFaultStatus
Definition: ARMControl.h:73
ARMControl::TranslationTable0
@ TranslationTable0
Definition: ARMControl.h:61
ARMControl::UserProcID
@ UserProcID
Definition: ARMControl.h:71
ARMControl::SystemFrequency
@ SystemFrequency
Definition: ARMControl.h:76
ARMControl::CacheClear
@ CacheClear
Definition: ARMControl.h:64
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
ARMControl::DataCacheClean
@ DataCacheClean
Definition: ARMControl.h:65
ARMControl::UnifiedTLBClear
@ UnifiedTLBClear
Definition: ARMControl.h:70
ARMControl::SystemControlFlags
SystemControlFlags
System Control flags.
Definition: ARMControl.h:82
ARMControl::DomainControl
@ DomainControl
Definition: ARMControl.h:60
ARMControl::set
void set(SystemControlFlags flags)
Set system control flags in CP15.
Definition: ARMControl.cpp:88
ARMControl::AuxControl
@ AuxControl
Definition: ARMControl.h:59
ARMControl::DataFaultStatus
@ DataFaultStatus
Definition: ARMControl.h:75
ARMControl.h
ARMControl::InstructionCacheClear
@ InstructionCacheClear
Definition: ARMControl.h:67
ARMControl::SystemControl
@ SystemControl
Definition: ARMControl.h:58
ARMControl::TranslationTable1
@ TranslationTable1
Definition: ARMControl.h:62
ARMControl::read
u32 read(Register reg) const
Read a register from the CP15.
Definition: ARMControl.cpp:29