#ifndef SDRAM_H
#define SDRAM_H

#include <vstypes.h>

#if 0
#define SDRAM_WRITE_LWORDS 8
#define SDRAM_READ_LWORDS 8
#else
#define SDRAM_WRITE_LWORDS 16
#define SDRAM_READ_LWORDS 8
#endif
#define SDRAM_WRITE_BYTES (4*SDRAM_WRITE_LWORDS)
#define SDRAM_READ_BYTES (4*SDRAM_READ_LWORDS)

#define SD_WRITE_TIMEOUT_MS 100
#define SD_READ_TIMEOUT_MS 100

#define SDRF_VERBOSE 1
#define SDRF_USE_12_MHZ_CLOCK_FOR_INIT 2


#ifndef ASM

/* After InitSdRam, 8<<sdrDensity = ddr size in MiB */
extern int sdrIoWidthIdx, sdrDensity, sdrType, sdrBanks, sdr12MHz;
extern u_int16 sdrSizeMiB;
extern u_int32 sdrStartAddr, sdrEndAddr;

int InitSdRam(register u_int16 sdrFlags);
int WriteSdRam(register const u_int16 *s, register u_int32 addr, register u_int16 bytes, register s_int16 swapWords);
int ReadSdRam(register u_int16 *d, register u_int32 addr, register u_int16 bytes, register s_int16 swapWords);

int SdRamWrite64N(register __i0 const u_int16 *s, register __a1 u_int16 n);
int SdRamWrite64NSwapWords(register __i0 const u_int16 *s, register __a1 u_int16 n);

int SdRamRead32N(register __reg_c u_int32 wAddr, register __i0 u_int16 *d, register __a1 u_int16 n);
int SdRamRead32NSwapWords(register __reg_c u_int32 wAddr, register __i0 u_int16 *d, register __a1 u_int16 n);

#endif /* !ASM */

#endif /* !SDRAM_H */
