conteeplongread.c 1.7 KB

/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1995, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright law.  They  may  not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 **************************************************************************/

#include "osint.h"
#include "controller.h"
#include "siint.h"

/*
 * This call issues read eeprom commands to pif to read
 * specified length of data from eeprom.
 * A countdown timer is used to wait for 15 msec before the
 * next write. So, cpu won't waste too much time in busy loop
 * and controller can work at the same time.
 *
 *
 * A value of 0 is returned if the calls succeed, otherwise
 * -1 is returned
 */

#define NUM_MESSAGE 1

s32
osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int length)
{
	s32	ret = 0;
	
	while (length > 0) {
		if ((ret = osEepromRead(mq, address, buffer)) != 0)
			return(ret);
		length -= EEPROM_BLOCK_SIZE;
		address++;
		buffer += EEPROM_BLOCK_SIZE;
#if 0
		osSetTimer(&__osEepromTimer, OS_USEC_TO_CYCLES(EEPROM_WAIT), 0, 
				&__osEepromTimerQ, &__osEepromTimerMsg);
		(void)osRecvMesg(&__osEepromTimerQ, NULL, OS_MESG_BLOCK);
#endif
	}
	return(ret);
}