On 64 bit coderelocation How we can launch
![On 64 -bit ‘code-relocation’ How we can launch a procedure in 64 -bit mode On 64 -bit ‘code-relocation’ How we can launch a procedure in 64 -bit mode](https://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-1.jpg)
On 64 -bit ‘code-relocation’ How we can launch a procedure in 64 -bit mode that resides in a page -frame at a high address
![64 -bit virtual address-space negative canonical addresses valid addresses 0 x. FFFFFFFF (128 Tera. 64 -bit virtual address-space negative canonical addresses valid addresses 0 x. FFFFFFFF (128 Tera.](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-2.jpg)
64 -bit virtual address-space negative canonical addresses valid addresses 0 x. FFFFFFFF (128 Tera. Bytes) 0 x. FFFF 8000000 Total number of locations having ‘canonical’ 64 -bit addresses is 248 Bytes (= 256 Tera. Bytes) positive canonical addresses Invalid address range valid addresses ‘non-canonical’ 64 -bit addresses 0 x 00007 FFFFFF (128 Tera. Bytes) 0 x 00000000
![The ‘canonical’ addresses • In a 64 -bit ‘canonical’ virtual address, the uppermost 16 The ‘canonical’ addresses • In a 64 -bit ‘canonical’ virtual address, the uppermost 16](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-3.jpg)
The ‘canonical’ addresses • In a 64 -bit ‘canonical’ virtual address, the uppermost 16 -bits are identical to bit 47 64 -bits sign-extension 48 -bits • The number of distinct virtual addresses actually implemented is 248 (= 256 TB)
![Our ‘highcode. s’ demo • We have created a demo-program which loads and executes Our ‘highcode. s’ demo • We have created a demo-program which loads and executes](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-4.jpg)
Our ‘highcode. s’ demo • We have created a demo-program which loads and executes a procedure that will reside at a very high location within the processor’s 64 -bit virtual address space • Some aspects of our design were shaped by limitations of our GNU software tools, and by our desire to keep the addressing ‘page-map’ tables as simple as possible
![Two components highdraw. b 0 x. FFFFC 0000000 Noncanonical addresses highcode. b virtual address Two components highdraw. b 0 x. FFFFC 0000000 Noncanonical addresses highcode. b virtual address](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-5.jpg)
Two components highdraw. b 0 x. FFFFC 0000000 Noncanonical addresses highcode. b virtual address space 0 x 00000010000
![Subfields of 64 -bit address 111111111 000000000 sign-extension (16 -bits) index into page-directory pointer Subfields of 64 -bit address 111111111 000000000 sign-extension (16 -bits) index into page-directory pointer](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-6.jpg)
Subfields of 64 -bit address 111111111 000000000 sign-extension (16 -bits) index into page-directory pointer table (9 -bits) index into the page-map level 4 table (9 -bits) index into page-directory (9 -bits) offset into page frame (12 -bits)
![4 -level page-mapping tables page directory pointer tables page-map level 4 table page directories 4 -level page-mapping tables page directory pointer tables page-map level 4 table page directories](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-7.jpg)
4 -level page-mapping tables page directory pointer tables page-map level 4 table page directories CR 3 page tables page frames
![Disk-partition’s layout /dev/sda 4 0 1 127 128 254 255 … unused The ‘highdraw. Disk-partition’s layout /dev/sda 4 0 1 127 128 254 255 … unused The ‘highdraw.](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-8.jpg)
Disk-partition’s layout /dev/sda 4 0 1 127 128 254 255 … unused The ‘highdraw. b’ program-component goes here The ‘highcode. b’ program-component goes here Our ‘cs 686 ipl. b’ boot-loader goes here (in ‘boot-sector’ of this disk-partition)
![‘ld’ handles 32 -bit relocations • We use a special linker-script to ‘relocate’ symbolic ‘ld’ handles 32 -bit relocations • We use a special linker-script to ‘relocate’ symbolic](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-9.jpg)
‘ld’ handles 32 -bit relocations • We use a special linker-script to ‘relocate’ symbolic addresses used in ‘highdraw. s’ OUTPUT_FORMAT(binary); SECTIONS {. = 0 x. FFFFC 0000000; . text : { *(. text) } =0 x 9090. data : { *(. data) } = 0 x 0000. bss : { *(. bss) } = 0 x 0000 }
![assembly commands • Assemble the ‘highcode. s’ component: $ as highcode. s –o highcode. assembly commands • Assemble the ‘highcode. s’ component: $ as highcode. s –o highcode.](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-10.jpg)
assembly commands • Assemble the ‘highcode. s’ component: $ as highcode. s –o highcode. o • Assemble the ‘highdraw. s’ component: $ as highdraw. s -o highdraw. o
![Linker commands • Link the ‘highcode. o’ component: $ ld highcode. o -T ldscript Linker commands • Link the ‘highcode. o’ component: $ ld highcode. o -T ldscript](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-11.jpg)
Linker commands • Link the ‘highcode. o’ component: $ ld highcode. o -T ldscript -o highcode. b • Assemble the ‘highdraw. s’ component: $ ld highdraw. o -T hiscript -o highdraw. b
![Installation commands • Install the ‘highcode. b’ component: $ dd if=highcode. b of=/dev/sda 4 Installation commands • Install the ‘highcode. b’ component: $ dd if=highcode. b of=/dev/sda 4](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-12.jpg)
Installation commands • Install the ‘highcode. b’ component: $ dd if=highcode. b of=/dev/sda 4 seek=1 • Assemble the ‘highdraw. s’ component: $ dd if=highdraw. b of=/dev/sda 4 seek=128
![Addition to ‘cs 686 ipl. s’ • We made a small but useful enhancement Addition to ‘cs 686 ipl. s’ • We made a small but useful enhancement](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-13.jpg)
Addition to ‘cs 686 ipl. s’ • We made a small but useful enhancement to our ‘cs 686 ipl. s’ boot-loader program, so subsequent program components will not need to repeat the search for the starting Logical Block Address of the disk-partition • That block-number is left in register EBX, where the next component can find it • It’s also written to the ROM-BIOS ‘mailbox’
![In-class exercise • After you have successfully downloaded, assembled, linked, installed, and executed the In-class exercise • After you have successfully downloaded, assembled, linked, installed, and executed the](http://slidetodoc.com/presentation_image_h2/81d5d034b1a486c51f3c84db4bdd3708/image-14.jpg)
In-class exercise • After you have successfully downloaded, assembled, linked, installed, and executed the ‘highcode. s’ demo-program, see if you can modify it so that its ‘highdraw’ codecomponent will reside at an even higher virtual address, namely: 0 x. FFFFFE 00000 instead of: 0 x. FFFFC 0000000
- Slides: 14