Changeset 4b4cfe0cd38d6ab371f58d76a171b5edcffd9787
- Timestamp:
- 10/29/09 23:14:57 (2 years ago)
- Author:
- Shao Miller <shao.miller@…>
- Children:
- 259c0dca1bc6ead6003fc504e136be67a1311abb
- Parents:
- 39adcc6d820d6432034c901f64a43dcd011ef1c3
- git-committer:
- Shao Miller <shao.miller@yrdsb.edu.on.ca> / 2009-10-29T19:14:57Z-0400
- Message:
-
[chain] Run Nindent on chain.c
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r39adcc
|
r4b4cfe
|
|
| 554 | 554 | return; |
| 555 | 555 | |
| 556 | | too_big: |
| | 556 | too_big: |
| 557 | 557 | error("Loader file too large\n"); |
| 558 | 558 | return; |
| 559 | 559 | |
| 560 | | enomem: |
| | 560 | enomem: |
| 561 | 561 | error("Out of memory\n"); |
| 562 | 562 | return; |
| … |
… |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | | |
| 600 | | |
| 601 | 599 | static uint32_t get_file_lba(const char *filename) |
| 602 | 600 | { |
| 603 | | com32sys_t inregs; |
| | 601 | com32sys_t inregs; |
| 604 | 602 | uint32_t lba; |
| 605 | 603 | |
| … |
… |
|
| 619 | 617 | |
| 620 | 618 | if ((inregs.eflags.l & EFLAGS_CF) || inregs.esi.w[0] == 0) { |
| 621 | | return 0; /* Filename not found */ |
| | 619 | return 0; /* Filename not found */ |
| 622 | 620 | } |
| 623 | 621 | |
| 624 | 622 | /* Since the first member is the LBA, we simply cast */ |
| 625 | | lba = *((uint32_t*)MK_PTR(inregs.ds, inregs.esi.w[0])); |
| 626 | | |
| 627 | | /* Clean the registers for the next call*/ |
| | 623 | lba = *((uint32_t *) MK_PTR(inregs.ds, inregs.esi.w[0])); |
| | 624 | |
| | 625 | /* Clean the registers for the next call */ |
| 628 | 626 | memset(&inregs, 0, sizeof(com32sys_t)); |
| 629 | 627 | |
| … |
… |
|
| 653 | 651 | uint32_t *checksum, *chkhead, *chktail; |
| 654 | 652 | size_t boot_size = SECTOR; |
| 655 | | |
| 656 | 653 | |
| 657 | 654 | openconsole(&dev_null_r, &dev_stdcon_w); |
| … |
… |
|
| 831 | 828 | |
| 832 | 829 | Offset Name Size Meaning |
| 833 | | 8 bi_pvd 4 bytes LBA of primary volume descriptor |
| 834 | | 12 bi_file 4 bytes LBA of boot file |
| 835 | | 16 bi_length 4 bytes Boot file length in bytes |
| 836 | | 20 bi_csum 4 bytes 32-bit checksum |
| 837 | | 24 bi_reserved 40 bytes Reserved |
| | 830 | 8 bi_pvd 4 bytes LBA of primary volume descriptor |
| | 831 | 12 bi_file 4 bytes LBA of boot file |
| | 832 | 16 bi_length 4 bytes Boot file length in bytes |
| | 833 | 20 bi_csum 4 bytes 32-bit checksum |
| | 834 | 24 bi_reserved 40 bytes Reserved |
| 838 | 835 | |
| 839 | 836 | The 32-bit checksum is the sum of all the 32-bit words in the |
| … |
… |
|
| 842 | 839 | |
| 843 | 840 | LBA of primary volume descriptor should already be set to 16. |
| 844 | | */ |
| 845 | | |
| 846 | | isolinux_bin = (unsigned char*)boot_sector; |
| | 841 | */ |
| | 842 | |
| | 843 | isolinux_bin = (unsigned char *)boot_sector; |
| 847 | 844 | |
| 848 | 845 | /* Get LBA address of bootfile */ |
| … |
… |
|
| 854 | 851 | } |
| 855 | 852 | /* Set it */ |
| 856 | | *((uint32_t*)&isolinux_bin[12]) = file_lba; |
| 857 | | |
| 858 | | /* Set boot file length */ |
| 859 | | *((uint32_t*)&isolinux_bin[16]) = boot_size; |
| | 853 | *((uint32_t *) & isolinux_bin[12]) = file_lba; |
| | 854 | |
| | 855 | /* Set boot file length */ |
| | 856 | *((uint32_t *) & isolinux_bin[16]) = boot_size; |
| 860 | 857 | |
| 861 | 858 | /* Calculate checksum */ |
| 862 | | checksum = (uint32_t*)&isolinux_bin[20]; |
| 863 | | chkhead = (uint32_t*)&isolinux_bin[64]; |
| 864 | | chktail = (uint32_t*)&isolinux_bin[boot_size-1]; |
| | 859 | checksum = (uint32_t *) & isolinux_bin[20]; |
| | 860 | chkhead = (uint32_t *) & isolinux_bin[64]; |
| | 861 | chktail = (uint32_t *) & isolinux_bin[boot_size - 1]; |
| 865 | 862 | /* Fresh checksum and clear possibly fractional uint32_t at the end */ |
| 866 | | *checksum = *((uint32_t*)&isolinux_bin[boot_size]) = 0; |
| 867 | | |
| 868 | | while (chkhead <= chktail) |
| 869 | | { |
| 870 | | *checksum += *chkhead++; |
| | 863 | *checksum = *((uint32_t *) & isolinux_bin[boot_size]) = 0; |
| | 864 | |
| | 865 | while (chkhead <= chktail) { |
| | 866 | *checksum += *chkhead++; |
| 871 | 867 | } |
| 872 | | } |
| 873 | | else { |
| 874 | | error("The isolinux= option is only valid when run from ISOLINUX\n"); |
| | 868 | } else { |
| | 869 | error |
| | 870 | ("The isolinux= option is only valid when run from ISOLINUX\n"); |
| 875 | 871 | goto bail; |
| 876 | 872 | } |
| 877 | | } |
| 878 | | |
| | 873 | } |
| | 874 | |
| 879 | 875 | } else if (partinfo) { |
| 880 | 876 | /* Actually read the boot sector */ |
| … |
… |
|
| 902 | 898 | do_boot(boot_sector, boot_size, ®s); |
| 903 | 899 | |
| 904 | | bail: |
| | 900 | bail: |
| 905 | 901 | return 255; |
| 906 | 902 | } |
| 907 | | |