Unverified Commit dff14ca8 authored by Arisotura's avatar Arisotura Committed by GitHub
Browse files

Merge pull request #682 from nadiaholmquist/slirp-merge

Merge slirp branch into master
parents 17ce4d2a 6a682a8e
......@@ -26,7 +26,7 @@ jobs:
&& sudo rm /etc/apt/sources.list \
&& sudo mv /etc/apt/sources.list{.new,} \
&& sudo apt-get update \
&& sudo apt-get install {gcc-10,g++-10,pkg-config}-aarch64-linux-gnu libsdl2-dev:arm64 qtbase5-dev:arm64
&& sudo apt-get install {gcc-10,g++-10,pkg-config}-aarch64-linux-gnu libsdl2-dev:arm64 qtbase5-dev:arm64 libslirp-dev:arm64
- name: Create build environment
run: mkdir ${{runner.workspace}}/build
- name: Configure
......
......@@ -23,17 +23,15 @@ jobs:
shell: bash
working-directory: ${{runner.workspace}}
run: | # Fetch a new version of CMake, because the default is too old.
wget -nv https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz \
&& tar -zxf cmake-$CMAKE_VERSION-Linux-x86_64.tar.gz \
&& sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list \
sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list \
&& sudo apt-get update \
&& sudo apt-get install gtk+-3.0 libcurl4-gnutls-dev libpcap0.8-dev libsdl2-dev qt5-default
&& sudo apt-get install cmake libcurl4-gnutls-dev libpcap0.8-dev libsdl2-dev qt5-default libslirp-dev
- name: Create build environment
run: mkdir ${{runner.workspace}}/build
- name: Configure
shell: bash
working-directory: ${{runner.workspace}}/build
run: ${{runner.workspace}}/cmake-$CMAKE_VERSION-Linux-x86_64/bin/cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Make
shell: bash
working-directory: ${{runner.workspace}}/build
......
......@@ -24,7 +24,7 @@ jobs:
choco install msys2
C:\tools\msys64\usr\bin\bash.exe -lc "pacman -Syuq --noconfirm"
- name: Install dependencies
run: C:\tools\msys64\usr\bin\bash.exe -lc "pacman -Sq --noconfirm git make mingw-w64-x86_64-{cmake,mesa,SDL2,qt5-static,toolchain}"
run: C:\tools\msys64\usr\bin\bash.exe -lc "pacman -Sq --noconfirm git make mingw-w64-x86_64-{cmake,mesa,SDL2,qt5-static,libslirp,toolchain}"
- name: Create build environment
run: |
New-Item -ItemType directory -Path ${{runner.workspace}}\melonDS\build
......
......@@ -635,7 +635,10 @@ void ARMv5::CP15Write(u32 id, u32 val)
}
if ((id&0xF00)!=0x700)
if ((id & 0xF00) == 0xF00) // test/debug shit?
return;
if ((id & 0xF00) != 0x700)
printf("unknown CP15 write op %03X %08X\n", id, val);
}
......@@ -729,6 +732,9 @@ u32 ARMv5::CP15Read(u32 id)
return ITCMSetting;
}
if ((id & 0xF00) == 0xF00) // test/debug shit?
return 0;
printf("unknown CP15 read op %03X\n", id);
return 0;
}
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......@@ -165,9 +165,37 @@ void ProcessBlock_CCM_Decrypt()
//printf("AES-CCM: "); _printhex2(data, 16);
Swap16(data_rev, data);
AES_CTR_xcrypt_buffer(&Ctx, data_rev, 16);
for (int i = 0; i < 16; i++) CurMAC[i] ^= data_rev[i];
AES_ECB_encrypt(&Ctx, CurMAC);
Swap16(data, data_rev);
//printf(" -> "); _printhex2(data, 16);
OutputFIFO->Write(*(u32*)&data[0]);
OutputFIFO->Write(*(u32*)&data[4]);
OutputFIFO->Write(*(u32*)&data[8]);
OutputFIFO->Write(*(u32*)&data[12]);
}
void ProcessBlock_CCM_Encrypt()
{
u8 data[16];
u8 data_rev[16];
*(u32*)&data[0] = InputFIFO->Read();
*(u32*)&data[4] = InputFIFO->Read();
*(u32*)&data[8] = InputFIFO->Read();
*(u32*)&data[12] = InputFIFO->Read();
//printf("AES-CCM: "); _printhex2(data, 16);
Swap16(data_rev, data);
for (int i = 0; i < 16; i++) CurMAC[i] ^= data_rev[i];
AES_CTR_xcrypt_buffer(&Ctx, data_rev, 16);
AES_ECB_encrypt(&Ctx, CurMAC);
Swap16(data, data_rev);
......@@ -232,7 +260,6 @@ void WriteCnt(u32 val)
OutputDMASize = dmasize_out[(val >> 14) & 0x3];
AESMode = (val >> 28) & 0x3;
if (AESMode == 1) printf("AES-CCM TODO\n");
if (val & (1<<24))
{
......@@ -245,6 +272,8 @@ void WriteCnt(u32 val)
// transfer start (checkme)
RemBlocks = BlkCnt >> 16;
if (AESMode == 0 && (!(val & (1<<20)))) printf("AES: CCM-DECRYPT MAC FROM WRFIFO, TODO\n");
if (RemBlocks > 0)
{
u8 key[16];
......@@ -365,14 +394,9 @@ void Update()
switch (AESMode)
{
case 0: ProcessBlock_CCM_Decrypt(); break;
case 1: ProcessBlock_CCM_Encrypt(); break;
case 2:
case 3: ProcessBlock_CTR(); break;
default:
// dorp
OutputFIFO->Write(InputFIFO->Read());
OutputFIFO->Write(InputFIFO->Read());
OutputFIFO->Write(InputFIFO->Read());
OutputFIFO->Write(InputFIFO->Read());
}
RemBlocks--;
......@@ -398,6 +422,24 @@ void Update()
if (CurMAC[15-i] != MAC[i]) Cnt &= ~(1<<21);
}
}
else if (AESMode == 1)
{
Ctx.Iv[13] = 0x00;
Ctx.Iv[14] = 0x00;
Ctx.Iv[15] = 0x00;
AES_CTR_xcrypt_buffer(&Ctx, CurMAC, 16);
u8 finalmac[16];
Swap16(finalmac, CurMAC);
OutputFIFO->Write(*(u32*)&finalmac[0]);
OutputFIFO->Write(*(u32*)&finalmac[4]);
OutputFIFO->Write(*(u32*)&finalmac[8]);
OutputFIFO->Write(*(u32*)&finalmac[12]);
// CHECKME
Cnt &= ~(1<<21);
}
else
{
// CHECKME
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
This diff is collapsed.
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......@@ -28,6 +28,8 @@ public:
DSi_NWifi(DSi_SDHost* host);
~DSi_NWifi();
void Reset();
void SendCMD(u8 cmd, u32 param);
void SendACMD(u8 cmd, u32 param);
......@@ -35,6 +37,10 @@ public:
void SetIRQ_F1_Counter(u32 n);
void _MSTimer();
static void MSTimer(u32 param);
private:
u32 TransferCmd;
u32 TransferAddr;
......@@ -60,9 +66,18 @@ private:
void HandleCommand();
void BMI_Command();
void HTC_Command();
void WMI_Command();
void SendWMIFrame(u8* data, u32 len, u8 ep, u8 flags, u16 ctrl);
void WMI_ConnectToNetwork();
void WMI_SendPacket(u16 len);
void SendWMIEvent(u8 ep, u16 id, u8* data, u32 len);
void SendWMIAck(u8 ep);
void SendWMIBSSInfo(u8 type, u8* data, u32 len);
void CheckRX();
void DrainRXBuffer();
u32 WindowRead(u32 addr);
void WindowWrite(u32 addr, u32 val);
......@@ -102,7 +117,7 @@ private:
while (!Mailbox[n]->IsEmpty()) Mailbox[n]->Read();
}
FIFO<u8>* Mailbox[8];
FIFO<u8>* Mailbox[9];
u8 F0_IRQEnable;
u8 F0_IRQStatus;
......@@ -116,6 +131,14 @@ private:
u32 EEPROMReady;
u32 BootPhase;
u32 ErrorMask;
u32 ScanTimer;
u64 BeaconTimer;
u32 ConnectionStatus;
u8 LANBuffer[2048];
};
#endif // DSI_NWIFI_H
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......@@ -112,8 +112,8 @@ void DSi_SDHost::Reset()
if (Ports[0]) delete Ports[0];
if (Ports[1]) delete Ports[1];
Ports[0] = NULL;
Ports[1] = NULL;
Ports[0] = nullptr;
Ports[1] = nullptr;
if (Num == 0)
{
......@@ -135,6 +135,9 @@ void DSi_SDHost::Reset()
Ports[0] = nwifi;
}
if (Ports[0]) Ports[0]->Reset();
if (Ports[1]) Ports[1]->Reset();
}
void DSi_SDHost::DoSavestate(Savestate* file)
......@@ -205,6 +208,18 @@ void DSi_SDHost::SetCardIRQ()
}
}
void DSi_SDHost::UpdateCardIRQ(u16 oldmask)
{
u16 oldflags = CardIRQStatus & ~oldmask;
u16 newflags = CardIRQStatus & ~CardIRQMask;
if ((oldflags == 0) && (newflags != 0)) // checkme
{
NDS::SetIRQ2(Num ? NDS::IRQ2_DSi_SDIO : NDS::IRQ2_DSi_SDMMC);
NDS::SetIRQ2(Num ? NDS::IRQ2_DSi_SDIO_Data1 : NDS::IRQ2_DSi_SD_Data1);
}
}
void DSi_SDHost::SendResponse(u32 val, bool last)
{
*(u32*)&ResponseBuffer[6] = *(u32*)&ResponseBuffer[4];
......@@ -448,6 +463,7 @@ u16 DSi_SDHost::Read(u32 addr)
case 0x0F6: return 0; // MMC write protect (always 0)
case 0x100: return Data32IRQ;
case 0x102: return 0;
case 0x104: return BlockLen32;
case 0x108: return BlockCount32;
}
......@@ -549,8 +565,8 @@ void DSi_SDHost::Write(u32 addr, u16 val)
u32 oldmask = IRQMask;
IRQMask = (IRQMask & 0x0000031D) | ((val & 0x8B7F) << 16);
UpdateIRQ(oldmask);
if (!DataFIFO[CurFIFO]->IsEmpty()) SetIRQ(24); // checkme
if (DataFIFO[CurFIFO]->IsEmpty()) SetIRQ(25); // checkme
//if (!DataFIFO[CurFIFO]->IsEmpty()) SetIRQ(24); // checkme
//if (DataFIFO[CurFIFO]->IsEmpty()) SetIRQ(25); // checkme
}
return;
......@@ -571,8 +587,13 @@ void DSi_SDHost::Write(u32 addr, u16 val)
CardIRQStatus &= val;
return;
case 0x038:
CardIRQMask = val & 0xC007;
SetCardIRQ();
{
u16 oldmask = CardIRQMask;
CardIRQMask = val & 0xC007;
UpdateCardIRQ(oldmask);
}
//CardIRQMask = val & 0xC007;
//SetCardIRQ();
return;
case 0x0D8:
......@@ -592,6 +613,9 @@ void DSi_SDHost::Write(u32 addr, u16 val)
SDOption = 0x40EE;
// TODO: CARD_IRQ_STAT
// TODO: FIFO16 shit
if (Ports[0]) Ports[0]->Reset();
if (Ports[1]) Ports[1]->Reset();
}
SoftReset = 0x0006 | (val & 0x0001);
return;
......@@ -601,6 +625,7 @@ void DSi_SDHost::Write(u32 addr, u16 val)
if (val & (1<<10)) DataFIFO32->Clear();
DataMode = ((DataCtl >> 1) & 0x1) & ((Data32IRQ >> 1) & 0x1);
return;
case 0x102: return;
case 0x104: BlockLen32 = val & 0x03FF; return;
case 0x108: BlockCount32 = val; return;
}
......@@ -701,6 +726,16 @@ DSi_MMCStorage::DSi_MMCStorage(DSi_SDHost* host, bool internal, const char* path
File = Platform::OpenLocalFile(path, "w+b");
}
}
}
DSi_MMCStorage::~DSi_MMCStorage()
{
if (File) fclose(File);
}
void DSi_MMCStorage::Reset()
{
// TODO: reset file access????
CSR = 0x00000100; // checkme
......@@ -723,11 +758,6 @@ DSi_MMCStorage::DSi_MMCStorage(DSi_SDHost* host, bool internal, const char* path
RWCommand = 0;
}
DSi_MMCStorage::~DSi_MMCStorage()
{
if (File) fclose(File);
}
void DSi_MMCStorage::SendCMD(u8 cmd, u32 param)
{
if (CSR & (1<<5))
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......@@ -95,6 +95,7 @@ private:
void ClearIRQ(u32 irq);
void SetIRQ(u32 irq);
void UpdateIRQ(u32 oldmask);
void UpdateCardIRQ(u16 oldmask);
};
......@@ -104,6 +105,8 @@ public:
DSi_SDDevice(DSi_SDHost* host) { Host = host; IRQ = false; }
~DSi_SDDevice() {}
virtual void Reset() = 0;
virtual void SendCMD(u8 cmd, u32 param) = 0;
virtual void ContinueTransfer() = 0;
......@@ -120,6 +123,8 @@ public:
DSi_MMCStorage(DSi_SDHost* host, bool internal, const char* path);
~DSi_MMCStorage();
void Reset();
void SetCID(u8* cid) { memcpy(CID, cid, 16); }
void SendCMD(u8 cmd, u32 param);
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
/*
Copyright 2016-2019 Arisotura
Copyright 2016-2020 Arisotura
This file is part of melonDS.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment