forked from len0rd/rockbox
arm: implement safe reads by intercepting the data abort handler.
Implement functions to read from a memory location and indicate failure in case this is not possible. Since we do not have a MMU, intercept the data abort handler and simply return when the abort comes from the safe read routines. Change-Id: I08f2e59898dcac893319a8150d4cf626f3adabbd Reviewed-on: http://gerrit.rockbox.org/207 Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
This commit is contained in:
parent
f33330c0ff
commit
d4674ed3b7
4 changed files with 181 additions and 6 deletions
33
lib/unwarminder/safe_read.h
Normal file
33
lib/unwarminder/safe_read.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2012 by Amaury Pouly
|
||||
*
|
||||
* 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 (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __SAFE_READ__
|
||||
#define __SAFE_READ__
|
||||
|
||||
#include "system.h"
|
||||
|
||||
/* Try to read an X-bit unsigned integer. If the address is not readable,
|
||||
* returns false. Otherwise returns true and store the result in *value
|
||||
* if value is not NULL */
|
||||
bool safe_read8(uint8_t *addr, uint8_t *value);
|
||||
bool safe_read16(uint16_t *addr, uint16_t *value);
|
||||
bool safe_read32(uint32_t *addr, uint32_t *value);
|
||||
|
||||
#endif /* __SAFE_READ__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue