{"action":"created","comment":{"url":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/comments/130238797","pull_request_review_id":53093636,"id":130238797,"diff_hunk":"@@ -187,22 +203,148 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 _BufferIn, u32 _Buffer\n     break;\n \n   case SEND_IF_COND:\n+    INFO_LOG(IOS_SD, \"SEND_IF_COND\");\n     // If the card can operate on the supplied voltage, the response echoes back the supply\n     // voltage and the check pattern that were set in the command argument.\n+    // This instruction is used to differentiate between protocol v1 and v2.\n+    m_Protocol = PROTOCOL_V2;\n     Memory::Write_U32(req.arg, _BufferOut);\n     break;\n \n   case SEND_CSD:\n-    INFO_LOG(IOS_SD, \"SEND_CSD\");\n-    // <WntrMute> shuffle2_, OCR: 0x80ff8000 CID: 0x38a00000 0x480032d5 0x3c608030 0x8803d420\n-    // CSD: 0xff928040 0xc93efbcf 0x325f5a83 0x00002600\n-\n-    // Values used currently are from lpfaint99\n-    Memory::Write_U32(0x80168000, _BufferOut);\n-    Memory::Write_U32(0xa9ffffff, _BufferOut + 4);\n-    Memory::Write_U32(0x325b5a83, _BufferOut + 8);\n-    Memory::Write_U32(0x00002e00, _BufferOut + 12);\n-    break;\n+  {\n+    u64 size = m_Card.GetSize();\n+    if (m_Protocol == PROTOCOL_V2)\n+    {\n+      if (size % (512 * 1024) != 0)\n+        WARN_LOG(IOS_SD, \"SDHC Card size cannot be divided by 1024 * 512\");\n+\n+      size /= 512 * 1024;\n+      size -= 1;\n+\n+      // 0b01               CSD_STRUCTURE (SDv2)\n+      // 0b000000           reserved\n+      // 0b00001110         TAAC (1.0 * 1ms)\n+      // 0b00000000         NSAC\n+      // 0b01011010         TRAN_SPEED (5.0 * 10 Mbit/s, max operating frequency)\n+\n+      // 0b010111110101     CCC (TODO: Figure out what each command class does)\n+      // 0b1001             READ_BL_LEN (512 bytes, fixed for SDHC)\n+      // 0b0                READ_BL_PARTIAL\n+      // 0b0                WRITE_BLK_MISALIGN\n+      // 0b0                READ_BLK_MISALIGN\n+      // 0b0                DSR_IMP (no driver stage register implemented)\n+      // 0b000000           reserved\n+      // 0b??????           C_SIZE (most significant 6 bits)\n+\n+      // 0b???????????????? C_SIZE (least significant 16 bits)\n+      // 0b0                reserved\n+      // 0b1                ERASE_BLK_EN\n+      // 0b1111111          SECTOR_SIZE\n+      // 0b0000000          WP_GRP_SIZE (not supported in SDHC)\n+\n+      // 0b0                WP_GRP_ENABLE\n+      // 0b00               reserved\n+      // 0b010              R2W_FACTOR (x4)\n+      // 0b1001             WRITE_BL_LEN (512 bytes)\n+      // 0b0                WRITE_BL_PARTIAL\n+      // 0b00000            reserved\n+      // 0b0                FILE_FORMAT_GRP\n+      // 0b0                COPY\n+      // 0b0                PERM_WRITE_PROTECT\n+      // 0b0                TMP_WRITE_PROTECT\n+      // 0b00               FILE_FORMAT\n+      // 0b00               reserved\n+      // 0b0000000          CRC\n+      // 0b1                reserved\n+\n+      // TODO: crc7\n+      u32 crc = 0;\n+\n+      Memory::Write_U32(0x400e005a, _BufferOut);\n+      Memory::Write_U32(0x5f590000 | (size >> 16), _BufferOut + 4);\n+      Memory::Write_U32(0x00007f80 | (size << 16), _BufferOut + 8);\n+      Memory::Write_U32(0x0a400001 | crc << 1, _BufferOut + 12);","path":"Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp","position":116,"original_position":116,"commit_id":"badd0ee33ba92934f95d094700578584b5513728","original_commit_id":"4cbb66637b974dec77544ab2f5772ad2a70767ab","user":{"login":"TBoshoven","id":1949124,"avatar_url":"https://avatars1.githubusercontent.com/u/1949124?v=4","gravatar_id":"","url":"https://api.github.com/users/TBoshoven","html_url":"https://github.com/TBoshoven","followers_url":"https://api.github.com/users/TBoshoven/followers","following_url":"https://api.github.com/users/TBoshoven/following{/other_user}","gists_url":"https://api.github.com/users/TBoshoven/gists{/gist_id}","starred_url":"https://api.github.com/users/TBoshoven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TBoshoven/subscriptions","organizations_url":"https://api.github.com/users/TBoshoven/orgs","repos_url":"https://api.github.com/users/TBoshoven/repos","events_url":"https://api.github.com/users/TBoshoven/events{/privacy}","received_events_url":"https://api.github.com/users/TBoshoven/received_events","type":"User","site_admin":false},"body":"These are just bits with values. I can't really make them descriptive other than saying they're byte X of the CSD...\r\nWhat I did do is factor out the CSD generation to separate functions for protocols v1 and v2.","created_at":"2017-07-30T10:28:09Z","updated_at":"2017-07-30T10:28:09Z","html_url":"https://github.com/dolphin-emu/dolphin/pull/5842#discussion_r130238797","pull_request_url":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/5842","_links":{"self":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/comments/130238797"},"html":{"href":"https://github.com/dolphin-emu/dolphin/pull/5842#discussion_r130238797"},"pull_request":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/5842"}}},"pull_request":{"url":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/5842","id":133103482,"html_url":"https://github.com/dolphin-emu/dolphin/pull/5842","diff_url":"https://github.com/dolphin-emu/dolphin/pull/5842.diff","patch_url":"https://github.com/dolphin-emu/dolphin/pull/5842.patch","issue_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/5842","number":5842,"state":"open","locked":false,"title":"Add support for SDHC","user":{"login":"TBoshoven","id":1949124,"avatar_url":"https://avatars1.githubusercontent.com/u/1949124?v=4","gravatar_id":"","url":"https://api.github.com/users/TBoshoven","html_url":"https://github.com/TBoshoven","followers_url":"https://api.github.com/users/TBoshoven/followers","following_url":"https://api.github.com/users/TBoshoven/following{/other_user}","gists_url":"https://api.github.com/users/TBoshoven/gists{/gist_id}","starred_url":"https://api.github.com/users/TBoshoven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TBoshoven/subscriptions","organizations_url":"https://api.github.com/users/TBoshoven/orgs","repos_url":"https://api.github.com/users/TBoshoven/repos","events_url":"https://api.github.com/users/TBoshoven/events{/privacy}","received_events_url":"https://api.github.com/users/TBoshoven/received_events","type":"User","site_admin":false},"body":"This add support for SD protocol 2 while staying compatible with protocol 1.01.\r\nMost of this is quite hacky, but it seems to be working well.\r\nBecause the original implementation was quite confusing I didn't touch most of the stuff I did not understand.","created_at":"2017-07-29T19:26:31Z","updated_at":"2017-07-30T10:28:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c1bbb0308e0cc0466f3a9abc027a1e55c4bf38f6","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/5842/commits","review_comments_url":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/5842/comments","review_comment_url":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/5842/comments","statuses_url":"https://api.github.com/repos/dolphin-emu/dolphin/statuses/badd0ee33ba92934f95d094700578584b5513728","head":{"label":"TBoshoven:sdhc-support","ref":"sdhc-support","sha":"badd0ee33ba92934f95d094700578584b5513728","user":{"login":"TBoshoven","id":1949124,"avatar_url":"https://avatars1.githubusercontent.com/u/1949124?v=4","gravatar_id":"","url":"https://api.github.com/users/TBoshoven","html_url":"https://github.com/TBoshoven","followers_url":"https://api.github.com/users/TBoshoven/followers","following_url":"https://api.github.com/users/TBoshoven/following{/other_user}","gists_url":"https://api.github.com/users/TBoshoven/gists{/gist_id}","starred_url":"https://api.github.com/users/TBoshoven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TBoshoven/subscriptions","organizations_url":"https://api.github.com/users/TBoshoven/orgs","repos_url":"https://api.github.com/users/TBoshoven/repos","events_url":"https://api.github.com/users/TBoshoven/events{/privacy}","received_events_url":"https://api.github.com/users/TBoshoven/received_events","type":"User","site_admin":false},"repo":{"id":98753793,"name":"dolphin","full_name":"TBoshoven/dolphin","owner":{"login":"TBoshoven","id":1949124,"avatar_url":"https://avatars1.githubusercontent.com/u/1949124?v=4","gravatar_id":"","url":"https://api.github.com/users/TBoshoven","html_url":"https://github.com/TBoshoven","followers_url":"https://api.github.com/users/TBoshoven/followers","following_url":"https://api.github.com/users/TBoshoven/following{/other_user}","gists_url":"https://api.github.com/users/TBoshoven/gists{/gist_id}","starred_url":"https://api.github.com/users/TBoshoven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TBoshoven/subscriptions","organizations_url":"https://api.github.com/users/TBoshoven/orgs","repos_url":"https://api.github.com/users/TBoshoven/repos","events_url":"https://api.github.com/users/TBoshoven/events{/privacy}","received_events_url":"https://api.github.com/users/TBoshoven/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TBoshoven/dolphin","description":"Dolphin is a GameCube / Wii emulator, allowing you to play games for these two platforms on PC with improvements.","fork":true,"url":"https://api.github.com/repos/TBoshoven/dolphin","forks_url":"https://api.github.com/repos/TBoshoven/dolphin/forks","keys_url":"https://api.github.com/repos/TBoshoven/dolphin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TBoshoven/dolphin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TBoshoven/dolphin/teams","hooks_url":"https://api.github.com/repos/TBoshoven/dolphin/hooks","issue_events_url":"https://api.github.com/repos/TBoshoven/dolphin/issues/events{/number}","events_url":"https://api.github.com/repos/TBoshoven/dolphin/events","assignees_url":"https://api.github.com/repos/TBoshoven/dolphin/assignees{/user}","branches_url":"https://api.github.com/repos/TBoshoven/dolphin/branches{/branch}","tags_url":"https://api.github.com/repos/TBoshoven/dolphin/tags","blobs_url":"https://api.github.com/repos/TBoshoven/dolphin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TBoshoven/dolphin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TBoshoven/dolphin/git/refs{/sha}","trees_url":"https://api.github.com/repos/TBoshoven/dolphin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TBoshoven/dolphin/statuses/{sha}","languages_url":"https://api.github.com/repos/TBoshoven/dolphin/languages","stargazers_url":"https://api.github.com/repos/TBoshoven/dolphin/stargazers","contributors_url":"https://api.github.com/repos/TBoshoven/dolphin/contributors","subscribers_url":"https://api.github.com/repos/TBoshoven/dolphin/subscribers","subscription_url":"https://api.github.com/repos/TBoshoven/dolphin/subscription","commits_url":"https://api.github.com/repos/TBoshoven/dolphin/commits{/sha}","git_commits_url":"https://api.github.com/repos/TBoshoven/dolphin/git/commits{/sha}","comments_url":"https://api.github.com/repos/TBoshoven/dolphin/comments{/number}","issue_comment_url":"https://api.github.com/repos/TBoshoven/dolphin/issues/comments{/number}","contents_url":"https://api.github.com/repos/TBoshoven/dolphin/contents/{+path}","compare_url":"https://api.github.com/repos/TBoshoven/dolphin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TBoshoven/dolphin/merges","archive_url":"https://api.github.com/repos/TBoshoven/dolphin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TBoshoven/dolphin/downloads","issues_url":"https://api.github.com/repos/TBoshoven/dolphin/issues{/number}","pulls_url":"https://api.github.com/repos/TBoshoven/dolphin/pulls{/number}","milestones_url":"https://api.github.com/repos/TBoshoven/dolphin/milestones{/number}","notifications_url":"https://api.github.com/repos/TBoshoven/dolphin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TBoshoven/dolphin/labels{/name}","releases_url":"https://api.github.com/repos/TBoshoven/dolphin/releases{/id}","deployments_url":"https://api.github.com/repos/TBoshoven/dolphin/deployments","created_at":"2017-07-29T19:13:02Z","updated_at":"2017-07-29T19:13:28Z","pushed_at":"2017-07-29T20:14:07Z","git_url":"git://github.com/TBoshoven/dolphin.git","ssh_url":"git@github.com:TBoshoven/dolphin.git","clone_url":"https://github.com/TBoshoven/dolphin.git","svn_url":"https://github.com/TBoshoven/dolphin","homepage":"https://dolphin-emu.org/","size":306666,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dolphin-emu:master","ref":"master","sha":"334e117da70e6a7704fc9d854de0e0c07bfbd51a","user":{"login":"dolphin-emu","id":5050316,"avatar_url":"https://avatars2.githubusercontent.com/u/5050316?v=4","gravatar_id":"","url":"https://api.github.com/users/dolphin-emu","html_url":"https://github.com/dolphin-emu","followers_url":"https://api.github.com/users/dolphin-emu/followers","following_url":"https://api.github.com/users/dolphin-emu/following{/other_user}","gists_url":"https://api.github.com/users/dolphin-emu/gists{/gist_id}","starred_url":"https://api.github.com/users/dolphin-emu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dolphin-emu/subscriptions","organizations_url":"https://api.github.com/users/dolphin-emu/orgs","repos_url":"https://api.github.com/users/dolphin-emu/repos","events_url":"https://api.github.com/users/dolphin-emu/events{/privacy}","received_events_url":"https://api.github.com/users/dolphin-emu/received_events","type":"Organization","site_admin":false},"repo":{"id":11577304,"name":"dolphin","full_name":"dolphin-emu/dolphin","owner":{"login":"dolphin-emu","id":5050316,"avatar_url":"https://avatars2.githubusercontent.com/u/5050316?v=4","gravatar_id":"","url":"https://api.github.com/users/dolphin-emu","html_url":"https://github.com/dolphin-emu","followers_url":"https://api.github.com/users/dolphin-emu/followers","following_url":"https://api.github.com/users/dolphin-emu/following{/other_user}","gists_url":"https://api.github.com/users/dolphin-emu/gists{/gist_id}","starred_url":"https://api.github.com/users/dolphin-emu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dolphin-emu/subscriptions","organizations_url":"https://api.github.com/users/dolphin-emu/orgs","repos_url":"https://api.github.com/users/dolphin-emu/repos","events_url":"https://api.github.com/users/dolphin-emu/events{/privacy}","received_events_url":"https://api.github.com/users/dolphin-emu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dolphin-emu/dolphin","description":"Dolphin is a GameCube / Wii emulator, allowing you to play games for these two platforms on PC with improvements.","fork":false,"url":"https://api.github.com/repos/dolphin-emu/dolphin","forks_url":"https://api.github.com/repos/dolphin-emu/dolphin/forks","keys_url":"https://api.github.com/repos/dolphin-emu/dolphin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dolphin-emu/dolphin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dolphin-emu/dolphin/teams","hooks_url":"https://api.github.com/repos/dolphin-emu/dolphin/hooks","issue_events_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/events{/number}","events_url":"https://api.github.com/repos/dolphin-emu/dolphin/events","assignees_url":"https://api.github.com/repos/dolphin-emu/dolphin/assignees{/user}","branches_url":"https://api.github.com/repos/dolphin-emu/dolphin/branches{/branch}","tags_url":"https://api.github.com/repos/dolphin-emu/dolphin/tags","blobs_url":"https://api.github.com/repos/dolphin-emu/dolphin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dolphin-emu/dolphin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dolphin-emu/dolphin/git/refs{/sha}","trees_url":"https://api.github.com/repos/dolphin-emu/dolphin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dolphin-emu/dolphin/statuses/{sha}","languages_url":"https://api.github.com/repos/dolphin-emu/dolphin/languages","stargazers_url":"https://api.github.com/repos/dolphin-emu/dolphin/stargazers","contributors_url":"https://api.github.com/repos/dolphin-emu/dolphin/contributors","subscribers_url":"https://api.github.com/repos/dolphin-emu/dolphin/subscribers","subscription_url":"https://api.github.com/repos/dolphin-emu/dolphin/subscription","commits_url":"https://api.github.com/repos/dolphin-emu/dolphin/commits{/sha}","git_commits_url":"https://api.github.com/repos/dolphin-emu/dolphin/git/commits{/sha}","comments_url":"https://api.github.com/repos/dolphin-emu/dolphin/comments{/number}","issue_comment_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues/comments{/number}","contents_url":"https://api.github.com/repos/dolphin-emu/dolphin/contents/{+path}","compare_url":"https://api.github.com/repos/dolphin-emu/dolphin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dolphin-emu/dolphin/merges","archive_url":"https://api.github.com/repos/dolphin-emu/dolphin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dolphin-emu/dolphin/downloads","issues_url":"https://api.github.com/repos/dolphin-emu/dolphin/issues{/number}","pulls_url":"https://api.github.com/repos/dolphin-emu/dolphin/pulls{/number}","milestones_url":"https://api.github.com/repos/dolphin-emu/dolphin/milestones{/number}","notifications_url":"https://api.github.com/repos/dolphin-emu/dolphin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dolphin-emu/dolphin/labels{/name}","releases_url":"https://api.github.com/repos/dolphin-emu/dolphin/releases{/id}","deployments_url":"https://api.github.com/repos/dolphin-emu/dolphin/deployments","created_at":"2013-07-22T09:07:57Z","updated_at":"2017-07-30T10:09:18Z","pushed_at":"2017-07-30T08:00:16Z","git_url":"git://github.com/dolphin-emu/dolphin.git","ssh_url":"git@github.com:dolphin-emu/dolphin.git","clone_url":"https://github.com/dolphin-emu/dolphin.git","svn_url":"https://github.com/dolphin-emu/dolphin","homepage":"https://dolphin-emu.org/","size":344581,"stargazers_count":3482,"watchers_count":3482,"language":"C++","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":903,"mirror_url":null,"open_issues_count":151,"forks":903,"open_issues":151,"watchers":3482,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/5842"},"html":{"href":"https://github.com/dolphin-emu/dolphin/pull/5842"},"issue":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/issues/5842"},"comments":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/issues/5842/comments"},"review_comments":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/5842/comments"},"review_comment":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/pulls/5842/commits"},"statuses":{"href":"https://api.github.com/repos/dolphin-emu/dolphin/statuses/badd0ee33ba92934f95d094700578584b5513728"}}}}
{"actor":{"display_login":"TBoshoven"}}