FreeNOS
Broadcom2836.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Ivan Tan
3 * Copyright (C) 2015 Niek Linnenbank
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "Broadcom2836.h"
20#include <Log.h>
21
23 : m_coreId(coreId)
24{
25 m_io.setBase(IOBase);
26}
27
29{
30 return Success;
31}
32
34 bool enable)
35{
36 u32 reg = CoreTimerRegister + (m_coreId * sizeof(u32));
37
38 switch (timer)
39 {
41 if (enable)
42 m_io.set(reg, (1 << 1));
43 else
44 m_io.unset(reg, (1 << 1));
45
46 return Success;
47
48 default:
49 break;
50 }
51 return NotFound;
52}
53
55{
56 if (timer == NonSecurePhysicalTimer)
57 return (m_io.read(CoreIrqRegister + (m_coreId * sizeof(u32))) & (1 << 1)) > 0;
58 else
59 return false;
60}
u8 coreId
Definition IntelACPI.h:1
void set(Address addr, u32 data)
Set bits in memory mapped register.
Definition ARMIO.h:109
void unset(Address addr, u32 data)
Unset bits in memory mapped register.
Definition ARMIO.h:122
u32 read(u32 reg) const
read from memory mapped I/O register
Definition ARMIO.h:62
Result setCoreTimerIrq(Timer timer, bool enable)
Set Core Timer interrupt.
Result initialize()
Initialize the Controller.
bool getCoreTimerIrqStatus(Timer timer) const
Get core timer interrupt status.
Result
Result code.
ARMIO m_io
I/O instance.
Size m_coreId
Core identifier.
Broadcom2836(Size coreId)
Constructor.
Timer
Hardware timers available in BCM 2836.
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128