XenevaOS
Loading...
Searching...
No Matches
uspios.h
Go to the documentation of this file.
1//
2// uspios.h
3//
4// External functions used by the USPi library
5//
6// USPi - An USB driver for Raspberry Pi written in C
7// Copyright (C) 2014-2018 R. Stange <rsta2@o2online.de>
8//
9// This program is free software: you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program. If not, see <http://www.gnu.org/licenses/>.
21//
22#ifndef _uspios_h
23#define _uspios_h
24
25#include <Mm/pmmngr.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31//
32// System configuration
33//
34// (Change this before you build the USPi library!)
35//
36#define GPU_L2_CACHE_ENABLED // normally enabled (can be disabled in config.txt)
37
38#define HZ 100 // timer ticks / second (set this to your timer interrupt frequency)
39
40// Default keyboard map (enable only one)
41//#define USPI_DEFAULT_KEYMAP_DE
42//#define USPI_DEFAULT_KEYMAP_ES
43//#define USPI_DEFAULT_KEYMAP_FR
44//#define USPI_DEFAULT_KEYMAP_IT
45#define USPI_DEFAULT_KEYMAP_UK
46//#define USPI_DEFAULT_KEYMAP_US
47
48// Undefine this if you want to use your own implementation of the functions in uspi/util.h
49#define USPI_PROVIDE_MEM_FUNCTIONS // mem*()
50#define USPI_PROVIDE_STR_FUNCTIONS // str*()
51
52//
53// Memory allocation
54//
55// (Must work from interrupt context)
56//
57void *malloc (unsigned nSize); // result must be 4-byte aligned
58void free (void *pBlock);
59
60//
61// Timer
62//
63void MsDelay (unsigned nMilliSeconds);
64void usDelay (unsigned nMicroSeconds);
65
66#ifndef AARCH64
67 typedef unsigned TKernelTimerHandle;
68#else
69 typedef unsigned long TKernelTimerHandle;
70#endif
71
72typedef void TKernelTimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext);
73
74// returns the timer handle (hTimer)
75unsigned StartKernelTimer (unsigned nHzDelay, // in HZ units (see "system configuration" above)
76 TKernelTimerHandler *pHandler,
77 void *pParam, void *pContext); // handed over to the timer handler
78
79void CancelKernelTimer (unsigned hTimer);
80
81//
82// Interrupt handling
83//
84typedef void TInterruptHandler (void *pParam);
85
86// USPi uses USB IRQ 9
87void ConnectInterrupt (unsigned nIRQ, TInterruptHandler *pHandler, void *pParam);
88
89//
90// Property tags (ARM -> VC)
91//
92// See: https://github.com/raspberrypi/firmware/wiki/Mailboxes
93//
94
95// returns 0 on failure
96int SetPowerStateOn (unsigned nDeviceId); // "set power state" to "on", wait until completed
97
98// returns 0 on failure
99int GetMACAddress (unsigned char Buffer[6]); // "get board MAC address"
100
101//
102// Logging
103//
104
105// Severity (change this before building if you want different values)
106#define LOG_ERROR 1
107#define LOG_WARNING 2
108#define LOG_NOTICE 3
109#define LOG_DEBUG 4
110
111void LogWrite (const char *pSource, // short name of module
112 unsigned Severity, // see above
113 const char *pMessage, ...); // uses printf format options
114
115//
116// Debug support
117//
118#ifndef NDEBUG
119
120// display "assertion failed" message and halt
121void uspi_assertion_failed (const char *pExpr, const char *pFile, unsigned nLine);
122
123// display hex dump (pSource can be 0)
124void DebugHexdump (const void *pBuffer, unsigned nBufLen, const char *pSource /* = 0 */);
125
126#endif
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif
void uspi_assertion_failed(const char *pExpr, const char *pFile, unsigned nLine)
Definition uspios.c:90
void * malloc(unsigned nSize)
Definition uspios.c:31
void ConnectInterrupt(unsigned nIRQ, TInterruptHandler *pHandler, void *pParam)
Definition uspios.c:68
unsigned StartKernelTimer(unsigned nHzDelay, TKernelTimerHandler *pHandler, void *pParam, void *pContext)
Definition uspios.c:79
void free(void *pBlock)
Definition uspios.c:35
int GetMACAddress(unsigned char Buffer[6])
Definition uspios.c:94
void CancelKernelTimer(unsigned hTimer)
Definition uspios.c:85
void TInterruptHandler(void *pParam)
Definition uspios.h:84
void TKernelTimerHandler(TKernelTimerHandle hTimer, void *pParam, void *pContext)
Definition uspios.h:72
void LogWrite(const char *pSource, unsigned Severity, const char *pMessage,...)
Definition uspios.c:46
void MsDelay(unsigned nMilliSeconds)
Definition uspios.c:39
void usDelay(unsigned nMicroSeconds)
Definition uspios.c:42
unsigned TKernelTimerHandle
Definition uspios.h:67
int SetPowerStateOn(unsigned nDeviceId)
Definition uspios.c:52
void DebugHexdump(const void *pBuffer, unsigned nBufLen, const char *pSource)
Definition uspios.c:98