FreeNOS
Broadcom2836.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 "Broadcom2836.h"
19 
21  : m_coreId(coreId)
22 {
24 }
25 
27 {
28  return Success;
29 }
30 
32  bool enable)
33 {
34  u32 reg = CoreTimerRegister + (m_coreId * sizeof(u32));
35 
36  switch (timer)
37  {
38  case PhysicalTimer1:
39  if (enable)
40  m_io.set(reg, (1 << 0));
41  else
42  m_io.unset(reg, (1 << 0));
43 
44  return Success;
45 
46  default:
47  break;
48  }
49  return NotFound;
50 }
51 
53 {
54  if (timer == PhysicalTimer1)
55  return (m_io.read(CoreIrqRegister + (m_coreId * sizeof(u32))) & (1 << 0)) > 0;
56  else
57  return false;
58 }
Broadcom2836::initialize
Result initialize()
Initialize the Controller.
Definition: Broadcom2836.cpp:26
Broadcom2836::getCoreTimerIrqStatus
bool getCoreTimerIrqStatus(Timer timer) const
Get core timer interrupt status.
Definition: Broadcom2836.cpp:52
Broadcom2836::CoreIrqRegister
@ CoreIrqRegister
Definition: Broadcom2836.h:52
Broadcom2836::CoreTimerRegister
@ CoreTimerRegister
Definition: Broadcom2836.h:51
Broadcom2836.h
Broadcom2836::Broadcom2836
Broadcom2836(Size coreId)
Constructor.
Definition: Broadcom2836.cpp:20
Broadcom2836::IOBase
static const Address IOBase
Base address for the BCM2836 I/O configuration.
Definition: Broadcom2836.h:43
Broadcom2836::Result
Result
Result code.
Definition: Broadcom2836.h:69
ARMIO::unset
void unset(Address addr, u32 data)
Unset bits in memory mapped register.
Definition: ARMIO.h:122
Broadcom2836::m_io
ARMIO m_io
I/O instance.
Definition: Broadcom2836.h:116
IO::setBase
void setBase(const Address base)
Set memory I/O base offset.
Definition: IO.cpp:33
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
ARMIO::read
u32 read(u32 reg) const
read from memory mapped I/O register
Definition: ARMIO.h:62
Broadcom2836::Timer
Timer
Hardware timers available in BCM 2836.
Definition: Broadcom2836.h:61
Broadcom2836::PhysicalTimer1
@ PhysicalTimer1
Definition: Broadcom2836.h:63
Broadcom2836::Success
@ Success
Definition: Broadcom2836.h:71
Broadcom2836::NotFound
@ NotFound
Definition: Broadcom2836.h:72
ARMIO::set
void set(Address addr, u32 data)
Set bits in memory mapped register.
Definition: ARMIO.h:109
Broadcom2836::setCoreTimerIrq
Result setCoreTimerIrq(Timer timer, bool enable)
Set Core Timer interrupt.
Definition: Broadcom2836.cpp:31
coreId
u8 coreId
Definition: IntelACPI.h:64
Broadcom2836::m_coreId
Size m_coreId
Core identifier.
Definition: Broadcom2836.h:113