mgh: fix for default HDD DMA mode, that wasn't correctly set
[open-ps2-loader.git] / modules / hdd / ps2hdd / misc.c
blob5490b142c8af1199f636a40c20f51a85c386bf97
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
10 # $Id: misc.c 1370 2007-01-17 02:28:14Z jbit $
11 # Miscellaneous routines
14 #include "hdd.h"
16 char myPassHash[APA_PASSMAX]={0};
18 void *allocMem(int size)
20 int intrStat;
21 void *mem;
23 CpuDisableIntr(&intrStat);
24 mem = AllocSysMemory(ALLOC_FIRST, size, NULL);
25 CpuEnableIntr(intrStat);
27 return mem;
30 int getPs2Time(ps2time *tm)
32 cd_clock_t cdtime;
33 s32 tmp;
34 ps2time timeBuf={
35 0, 0x0D, 0x0E, 0x0A, 0x0D, 1, 2003// used if can not get time...
38 if(CdReadClock(&cdtime)!=0 && cdtime.stat==0)
40 tmp=cdtime.second>>4;
41 timeBuf.sec=(u32)(((tmp<<2)+tmp)<<1)+(cdtime.second&0x0F);
42 tmp=cdtime.minute>>4;
43 timeBuf.min=(((tmp<<2)+tmp)<<1)+(cdtime.minute&0x0F);
44 tmp=cdtime.hour>>4;
45 timeBuf.hour=(((tmp<<2)+tmp)<<1)+(cdtime.hour&0x0F);
46 // timeBuf.hour = (timeBuf.hour + 4) % 24; // TEMP FIX (need to deal with timezones?) ... aparently not
47 tmp=cdtime.day>>4;
48 timeBuf.day=(((tmp<<2)+tmp)<<1)+(cdtime.day&0x0F);
49 tmp=cdtime.month>>4;
50 timeBuf.month=(((tmp<<2)+tmp)<<1)+(cdtime.month&0x0F);
51 tmp=cdtime.year>>4;
52 timeBuf.year=(((tmp<<2)+tmp)<<1)+(cdtime.year&0xF)+2000;
54 memcpy(tm, &timeBuf, sizeof(ps2time));
55 return 0;
58 int passcmp(char *pw1, char *pw2)
60 if(pw2==NULL) pw2=myPassHash;
61 return memcmp(pw1, pw2, APA_PASSMAX) ? -EACCES : 0;
64 int getIlinkID(u8 *idbuf)
66 int err=0;
68 memset(idbuf, 0, 32);
70 // v12/v13 HDD fix: do not check iLinkID
71 //if(CdReadIlinkID(idbuf, &err))
72 // if(err==0)
73 // return 0;
74 //dprintf1("ps2hdd: Error: cannot get ilink id\n");
75 //return -EIO;
76 CdReadIlinkID(idbuf, &err);
77 return 0;