opuntiaOS - an operating system targeting x86 and ARMv7
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 59 lines 1.5 kB view raw
1/* 2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors. 3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com> 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#ifndef _KERNEL_DRIVERS_AARCH32_FPUV4_H 10#define _KERNEL_DRIVERS_AARCH32_FPUV4_H 11 12#include <drivers/driver_manager.h> 13#include <libkern/mask.h> 14#include <libkern/types.h> 15#include <platform/aarch32/interrupts.h> 16#include <platform/aarch32/registers.h> 17#include <platform/aarch32/target/cortex-a15/device_settings.h> 18 19#define FPU_STATE_ALIGNMENT (16) 20 21typedef struct { 22 uint64_t d[32]; 23} __attribute__((aligned(FPU_STATE_ALIGNMENT))) fpu_state_t; 24 25void fpuv4_install(); 26void fpu_init_state(fpu_state_t* new_fpu_state); 27extern uint32_t read_fpexc(); 28extern void write_fpexc(uint32_t); 29extern void fpu_save(void*); 30extern void fpu_restore(void*); 31 32static inline void fpu_enable() 33{ 34 write_fpexc(read_fpexc() | (1 << 30)); 35} 36 37static inline void fpu_disable() 38{ 39 write_fpexc(read_fpexc() & (~(1 << 30))); 40} 41 42static inline int fpu_is_avail() 43{ 44 return (((read_cpacr() >> 20) & 0b1111) == 0b1111); 45} 46 47static inline void fpu_make_avail() 48{ 49 write_cpacr(read_cpacr() | ((0b1111) << 20)); 50} 51 52static inline void fpu_make_unavail() 53{ 54 // Simply turn it off to make it unavailble. 55 uint32_t val = read_cpacr() & (~((0b1111) << 20)); 56 write_cpacr(val | ((0b0101) << 20)); 57} 58 59#endif //_KERNEL_DRIVERS_AARCH32_FPUV4_H