conteeplongwrite.c
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**************************************************************************
* *
* 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 write eeprom commands to pif to write
* specified length of data to 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
osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int length)
{
s32 ret = 0;
while (length > 0) {
if ((ret = osEepromWrite(mq, address, buffer)) != 0)
return(ret);
length -= EEPROM_BLOCK_SIZE;
address++;
buffer += EEPROM_BLOCK_SIZE;
osSetTimer(&__osEepromTimer, OS_USEC_TO_CYCLES(EEPROM_WAIT), 0,
&__osEepromTimerQ, &__osEepromTimerMsg);
(void)osRecvMesg(&__osEepromTimerQ, NULL, OS_MESG_BLOCK);
}
return(ret);
}