mirror of
https://github.com/ipxe/ipxe
synced 2026-01-03 02:13:23 +03:00
[arm] Add support for 32-bit ARM
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
88
src/arch/arm/core/arm_io.c
Normal file
88
src/arch/arm/core/arm_io.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* 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 2 of the
|
||||
* License, or 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
* You can also choose to distribute this program under the terms of
|
||||
* the Unmodified Binary Distribution Licence (as given in the file
|
||||
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <ipxe/io.h>
|
||||
#include <ipxe/arm_io.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
* iPXE I/O API for ARM
|
||||
*
|
||||
*/
|
||||
|
||||
/** An ARM I/O qword */
|
||||
union arm_io_qword {
|
||||
uint64_t qword;
|
||||
uint32_t dword[2];
|
||||
};
|
||||
|
||||
/**
|
||||
* Read 64-bit qword from memory-mapped device
|
||||
*
|
||||
* @v io_addr I/O address
|
||||
* @ret data Value read
|
||||
*
|
||||
* This is not atomic for ARM.
|
||||
*/
|
||||
static uint64_t arm_readq ( volatile uint64_t *io_addr ) {
|
||||
volatile union arm_io_qword *ptr =
|
||||
container_of ( io_addr, union arm_io_qword, qword );
|
||||
union arm_io_qword tmp;
|
||||
|
||||
tmp.dword[0] = readl ( &ptr->dword[0] );
|
||||
tmp.dword[1] = readl ( &ptr->dword[1] );
|
||||
return tmp.qword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write 64-bit qword to memory-mapped device
|
||||
*
|
||||
* @v data Value to write
|
||||
* @v io_addr I/O address
|
||||
*
|
||||
* This is not atomic for ARM.
|
||||
*/
|
||||
static void arm_writeq ( uint64_t data, volatile uint64_t *io_addr ) {
|
||||
volatile union arm_io_qword *ptr =
|
||||
container_of ( io_addr, union arm_io_qword, qword );
|
||||
union arm_io_qword tmp;
|
||||
|
||||
tmp.qword = data;
|
||||
writel ( tmp.dword[0], &ptr->dword[0] );
|
||||
writel ( tmp.dword[1], &ptr->dword[1] );
|
||||
}
|
||||
|
||||
PROVIDE_IOAPI_INLINE ( arm, phys_to_bus );
|
||||
PROVIDE_IOAPI_INLINE ( arm, bus_to_phys );
|
||||
PROVIDE_IOAPI_INLINE ( arm, readb );
|
||||
PROVIDE_IOAPI_INLINE ( arm, readw );
|
||||
PROVIDE_IOAPI_INLINE ( arm, readl );
|
||||
PROVIDE_IOAPI_INLINE ( arm, writeb );
|
||||
PROVIDE_IOAPI_INLINE ( arm, writew );
|
||||
PROVIDE_IOAPI_INLINE ( arm, writel );
|
||||
PROVIDE_IOAPI_INLINE ( arm, iodelay );
|
||||
PROVIDE_IOAPI_INLINE ( arm, mb );
|
||||
PROVIDE_IOAPI ( arm, readq, arm_readq );
|
||||
PROVIDE_IOAPI ( arm, writeq, arm_writeq );
|
||||
Reference in New Issue
Block a user