began work to add privilege
parent
79da473bd0
commit
04548126b5
@ -0,0 +1,26 @@
|
||||
#ifndef PRIV_GPIO_H_
|
||||
#define PRIV_GPIO_H_
|
||||
|
||||
#define GPIO_MODE 0
|
||||
#define GPIO_TYPE 1
|
||||
#define GPIO_PUPD 2
|
||||
#define GPIO_SPEED 3
|
||||
#define GPIO_OUT 4
|
||||
|
||||
void gpio(uint32_t call, uint32_t port, uint32_t pin, uint32_t value)
|
||||
{
|
||||
register uint32_t r0 asm("r0") = call;
|
||||
register uint32_t r1 asm("r1") = port;
|
||||
register uint32_t r2 asm("r2") = pin;
|
||||
register uint32_t r3 asm("r3") = value;
|
||||
|
||||
asm("\
|
||||
mov r0, %0; \
|
||||
mov r1, %1; \
|
||||
mov r2, %2; \
|
||||
mov r3, %3; \
|
||||
svc 1; \
|
||||
" :: "r" (r0), "r" (r1), "r" (r2), "r" (r3));
|
||||
}
|
||||
|
||||
#endif // PRIV_GPIO_H_
|
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file svc.c
|
||||
* An unused handler for SVC calls
|
||||
* TODO: use SVC calls, possibly allowing for switch to unprivileged mode?
|
||||
*
|
||||
* Copyright (C) 2018 Clyne Sullivan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gpio.h>
|
||||
#include <clock.h>
|
||||
|
||||
extern void gpio_svc(uint32_t *);
|
||||
|
||||
void svc_handler(uint32_t *args)
|
||||
{
|
||||
uint32_t svc_number = ((char *)args[6])[-2];
|
||||
|
||||
switch (svc_number) {
|
||||
case 1:
|
||||
gpio_svc(args);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SVC_Handler(void) {
|
||||
uint32_t *args;
|
||||
|
||||
asm("\
|
||||
tst lr, #4; \
|
||||
ite eq; \
|
||||
mrseq %0, msp; \
|
||||
mrsne %0, psp; \
|
||||
" : "=r" (args));
|
||||
|
||||
svc_handler(args);
|
||||
}
|
||||
|
Loading…
Reference in New Issue