To get to Long Mode we need to follow the sequence:
Note the last three steps - unlike Protected Mode, if you want to use Long Mode then you must use Paging; even after you enable Long Mode it doesn't take effect until you also enable Paging. In many ways that's the most difficult part of getting the cpu working as a 64-bit processor.
The code covering this process can be found in the files:
The code in these files runs in 16-bit or 32-bit mode and is concerned with setting the system up to transfer to 64-bit mode. The final instruction in startup.s is a jump to the start of the 64-bit code in os.s.