📄 hal_nor.c
字号:
/******************************************************************************/
/* */
/* Copyright (C), 1995-2006, msystems Ltd. All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions are */
/* met: */
/* 1. Redistributions of source code must retain the above copyright notice, */
/* this list of conditions and the following disclaimer. */
/* 2. Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution. */
/* 3. Neither the name of msystems nor the names of its contributors may be */
/* used to endorse or promote products derived from this software without */
/* specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/******************************************************************************/
/*
* $Log: V:/PVCSDB/DiskOnChip/archives/Test for 7.x/src/H3/hal_nor.c-arc $
*
* Rev 1.23 Sep 11 2006 13:45:26 yaniv.iarovici
* Legal header added
*
* Rev 1.22 Aug 09 2006 17:26:56 Polina.Marimont
* initial for DOC Driver 1.0
*
*/
/*
* includes
*/
#include "flbase.h"
#include "hal_nor.h"
#include "doch_sys.h"
#include "doch_ata.h"
#ifdef FL_MIGRATION_VERSION
#include "docsys.h"
#endif /*FL_MIGRATION_VERSION*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Externals
*/
extern FLDword gAccessLayerType;
#ifdef __cplusplus
}
#endif
#ifdef DOCH_USE_FUNC
#ifdef __cplusplus
extern "C" {
#endif
/*
* Externals
*/
extern FLDword gAccessLayerType;
/*
* global vars
*/
/******************************************************************************
* *
* d o c h _ s y s _ i n i t *
* *
* Initialize BSP specific part of DOCH driver. *
* *
* Parameters : *
* socketNo : Socket # (0...DOCH_MAX_SOCKETS-1) *
* *
* Returns : *
* 0 if success, otherwise respective error code. *
* *
******************************************************************************/
DOCH_Error hal_init_nor ( FLSNative socketNo)
{
DOCH_Socket* pdev;
DOCH_get_socket(pdev, socketNo);
/*If socket is not registered, return error*/
if(pdev == NULL)
return DOCH_DiskNotFound;
/*Register access layer routines*/
pdev->halRoutines.hal_get_ata_reg = hal_get_ata_reg_nor;
pdev->halRoutines.hal_set_ata_reg = hal_set_ata_reg_nor;
pdev->halRoutines.hal_get_ctrl_reg = hal_get_ctrl_reg_nor;
pdev->halRoutines.hal_set_ctrl_reg = hal_set_ctrl_reg_nor;
pdev->halRoutines.hal_blk_read = hal_blk_read_nor;
pdev->halRoutines.hal_blk_write = hal_blk_write_nor;
pdev->halRoutines.hal_doch_release = doch_sys_release_nor;
gAccessLayerType = DOCH_AL_NOR;
return DOCH_OK;
}
/*********************************************************/
/* Function name : doch_sys_release_nor*/
/* Description : */
/* Return type : */
/* Argument : int socketNo*/
/*********************************************************/
FLSNative doch_sys_release_nor(int socketNo)
{
return flOK;
}
/******************************************************************************
* *
* d o c h_ s y s _ g e t _ r e g X *
* *
* Reads DOCH register. *
* *
* Parameters : *
* base : pointer to the base of DOCH register set *
* reg : ATA register number *
* *
* Returns : *
* value of specified register *
* *
******************************************************************************/
FLByte hal_get_ata_reg_nor(volatile FLByte *base, FLSNative reg)
{
volatile FLWord* vPtr = (volatile FLWord*)addToFarPointer(base, (reg<<1) + DOCH_CONT_REG_AREA);
FLWord val = DOCHREAD_IO_WORD(vPtr);
#ifdef DOCH_BIG_ENDIAN
return (FLByte)(val>>8); /*Value is returned in the higher byte*/
#else /*DOCH_BIG_ENDIAN*/
return (FLByte)(val);
#endif /*DOCH_BIG_ENDIAN*/
}
FLWord hal_get_ctrl_reg_nor ( volatile FLByte * base,
FLSNative reg )
{
volatile FLWord* vPtr = (volatile FLWord*)addToFarPointer(base, reg);
FLWord regVal = DOCHREAD_IO_WORD(vPtr);
#ifdef DOCH_BIG_ENDIAN
return ((regVal<<8) | (regVal>>8)); /*Swap high/low bytes*/
#else /*DOCH_BIG_ENDIAN*/
return regVal;
#endif /*DOCH_BIG_ENDIAN*/
}
/******************************************************************************
* *
* d o c h _ s y s _ s e t _ r e g X *
* *
* Writes DOCH register. *
* *
* Parameters : *
* base : pointer to the base of DOCH register set *
* reg : ATA register number *
* val : value to write to register *
* *
* Returns : *
* value of specified register *
* *
******************************************************************************/
void hal_set_ata_reg_nor( volatile FLByte * base,
FLSNative reg,
FLNative val )
{
volatile FLWord* vPtr = (volatile FLWord*)addToFarPointer(base, (reg<<1) + DOCH_CONT_REG_AREA);
#ifdef DOCH_BIG_ENDIAN
val = ((val>>8) | (val<<8));
#endif /*DOCH_BIG_ENDIAN*/
DOCHWRITE_IO_WORD((FLWord)val, vPtr);
}
void hal_set_ctrl_reg_nor ( volatile FLByte * base,
FLSNative reg,
FLNative val )
{
#ifdef DOCH_BIG_ENDIAN
val = ((val>>8) | (val<<8));
#endif /*DOCH_BIG_ENDIAN*/
DOCHWRITE_IO_WORD((FLWord)val, (base + reg));
}
/******************************************************************************
* *
* b l k _ r e a d_ u s i n g _ d a t a _ r e g *
* *
* Read specified # of bytes through the ATA data register *
* *
* Parameters : *
* base : pointer to the base of DOCH register set *
* buf : buffer to write from *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -