init.c 1.07 KB

#include "ddwriteint.h"

/*
 * Static variables
 */
static OSMesg		diskQBuf;

#define NUM_CMD_MSGS	8
static OSMesg           cmdQBuf[8];

static char	buffer1[240 * SECPERBLOCK + 15];
static char	buffer2[240 * SECPERBLOCK + 15];

/*
 * Global variables
 */
OSMesgQueue	__ddDiskQ;		/* post queue */

void	*__ddBufp1;
void	*__ddBufp2;

u32	__ddWriteActive = 0;
s32	__ddWriteError = 0;


/*
 * ddWrite, ddGetInfo に必要な初期化をする。
 * 1回だけでよい。
 */
void __ddInit(void)
{
  LEOError	error;


  __ddWriteActive = 1;
  
  __ddBufp1 = OS_DCACHE_ROUNDUP_ADDR((void *)buffer1);
  __ddBufp2 = OS_DCACHE_ROUNDUP_ADDR((void *)buffer2);

  osCreateMesgQueue(&__ddDiskQ, &diskQBuf, 1);

  error = (LEOError)LeoCreateLeoManager((OSPri)OS_PRIORITY_LEOMGR-1,
					(OSPri)OS_PRIORITY_LEOMGR,
					cmdQBuf, NUM_CMD_MSGS);

  if (error == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE)
  {
    __ddWriteError = (s32)error;
    return;
  }
  
  LEO_country_code = 0;
  SAVE_COUNTRY(0);		/* paranoia */

  /*
   * Clear "reset" flag.
   */
  LeoResetClear();

  __ddWriteError = (s32)0;
  return;

} /* __ddInit() */