{"action":"created","issue":{"url":"https://api.github.com/repos/redox-os/redox/issues/499","repository_url":"https://api.github.com/repos/redox-os/redox","labels_url":"https://api.github.com/repos/redox-os/redox/issues/499/labels{/name}","comments_url":"https://api.github.com/repos/redox-os/redox/issues/499/comments","events_url":"https://api.github.com/repos/redox-os/redox/issues/499/events","html_url":"https://github.com/redox-os/redox/pull/499","id":131511119,"number":499,"title":"x86_64 interrupt handling","user":{"login":"Roxxik","id":9296375,"avatar_url":"https://avatars.githubusercontent.com/u/9296375?v=3","gravatar_id":"","url":"https://api.github.com/users/Roxxik","html_url":"https://github.com/Roxxik","followers_url":"https://api.github.com/users/Roxxik/followers","following_url":"https://api.github.com/users/Roxxik/following{/other_user}","gists_url":"https://api.github.com/users/Roxxik/gists{/gist_id}","starred_url":"https://api.github.com/users/Roxxik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roxxik/subscriptions","organizations_url":"https://api.github.com/users/Roxxik/orgs","repos_url":"https://api.github.com/users/Roxxik/repos","events_url":"https://api.github.com/users/Roxxik/events{/privacy}","received_events_url":"https://api.github.com/users/Roxxik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-04T23:59:46Z","updated_at":"2016-02-05T17:01:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/redox-os/redox/pulls/499","html_url":"https://github.com/redox-os/redox/pull/499","diff_url":"https://github.com/redox-os/redox/pull/499.diff","patch_url":"https://github.com/redox-os/redox/pull/499.patch"},"body":"1. I don't know why there was kernel relocation code. on i386 there is none. And the relocation code as it was did quite some garbage. That's why i removed it.\r\nIt moved the memory from kernel_file + 0xB000 to kernel_file, so overwrote the kernel, and afterwards cleared 0xB000 Bytes from the end of the - now overwritten - kernel. And this memory is taken from 0x80000+ where there could be some parts from EBDA, which could have led to the Page Fault. Tried to move the kernel to some higher address(1MB+) and it worked, but i don't know if this memory is used elsewhere, and i don't see the purpose in moving the kernel. If this is needed for something and someone knows where to place the kernel, i'd be happy to put the code back.\r\n\r\n2. Where does this MagicValue(tm) 0x18 come from? in\r\n\r\n        mov eax, [kernel_file + 0x18]\r\n        mov [interrupts.handler], rax\r\n\r\n    It works on i386 but on x86_64 it points in the midst of zeroed memory\r\n\r\n3. Interrupts are working now, the page fault experienced before was due to writing to protected lower memory (my theory, see above) and the kernel exception handler wasn't yet set up, which led to a triple fault.\r\n\r\ntl;dr: We have interrupts, but I don't know where the kernel interrupt handler lives, so we can't do much with those interrupts."},"comment":{"url":"https://api.github.com/repos/redox-os/redox/issues/comments/180441186","html_url":"https://github.com/redox-os/redox/pull/499#issuecomment-180441186","issue_url":"https://api.github.com/repos/redox-os/redox/issues/499","id":180441186,"user":{"login":"Roxxik","id":9296375,"avatar_url":"https://avatars.githubusercontent.com/u/9296375?v=3","gravatar_id":"","url":"https://api.github.com/users/Roxxik","html_url":"https://github.com/Roxxik","followers_url":"https://api.github.com/users/Roxxik/followers","following_url":"https://api.github.com/users/Roxxik/following{/other_user}","gists_url":"https://api.github.com/users/Roxxik/gists{/gist_id}","starred_url":"https://api.github.com/users/Roxxik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roxxik/subscriptions","organizations_url":"https://api.github.com/users/Roxxik/orgs","repos_url":"https://api.github.com/users/Roxxik/repos","events_url":"https://api.github.com/users/Roxxik/events{/privacy}","received_events_url":"https://api.github.com/users/Roxxik/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T17:01:10Z","updated_at":"2016-02-05T17:01:10Z","body":"Oh thanks, i'll do that immediately.\r\n\r\nI think the current kernel is to big to fit into low memory, which provides us at most 512KiB continuos Memory, and only after overriding the the BIOS IVT and BDA and our Boot Sector\r\n\r\n0x000000 - 0x0004FF (reserved) used by BIOS, do not override until the kernel is loaded\r\n0x000500 - 0x007BFF ( usable ) unused, stack pointer grows from 0x7C00 downwards\r\n0x007C00 - 0x007DFF ( usable ) Boot Sector, loaded from BIOS\r\n0x007E00 - 0x07FFFF ( usable ) Unused, the kernel will be loaded here\r\n0x080000 - 0x09FBFF (reserved) should be free, not sure, there might be some EBDA here\r\n0x09FC00 - 0x09FFFF (reserved) EBDA, on most computers\r\n0x0A0000 - 0x0FFFFF (reserved) video memory\r\nusable after A20-Line is enabled\r\n0x100000 - 0xEFFFFF ( usable ) upper memory\r\n0xF00000 - 0xFFFFFF (reserved) ISA memory hole\r\n\r\nkernel needs 517KiB, 394KiB after stripping\r\nPaging needs 12KiB, 3 tables\r\nstack needs ???\r\nMemory Map needs some memory too, with current bochs settings it needs 78 Bytes, could be more with more memory, other BIOS, i don't know\r\n\r\nthis is in total (assuming 1KiB stack and 1KiB Memory Map) 408 KiB, after striping the kernel (i don't know if it boots without debug information, and where all the sections land) and i don't believe the kernel is about to shrink, so we need to think about restructuring the boot process.\r\n\r\nenabling the A20-Line earlier should leave us with enough memory to keep going (14MiB)\r\nIMPORTANT the BIOS can NOT write to higher mem (> 1MiB) so we'd need to load the kernel piece by piece to low mem and copy it up to high mem"}}