summaryrefslogtreecommitdiff
path: root/src/Dolphin/card/CARDNet.c
blob: 828dbad9ab4640d06bd63c4de1f7fe541f21418a (plain)
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
#include <dolphin/card.h>
#include <dolphin/dsp.h>
#include <dolphin/dvd.h>
#include <dolphin/os.h>

#include <dolphin/CARDPriv.h>

u16 __CARDVendorID = 0xffff;

s32 CARDGetSerialNo(s32 chan, u64* serialNo) {
  CARDControl* card;
  CARDID* id;
  int i;
  u64 code;
  s32 result;

  if (!(0 <= chan && chan < 2)) {
    return CARD_RESULT_FATAL_ERROR;
  }

  result = __CARDGetControlBlock(chan, &card);
  if (result < 0) {
    return result;
  }

  id = (CARDID*)card->workArea;
  for (code = 0, i = 0; i < sizeof(id->serial) / sizeof(u64); ++i) {
    code ^= *(u64*)&id->serial[sizeof(u64) * i];
  }
  *serialNo = code;

  return __CARDPutControlBlock(card, CARD_RESULT_READY);
}