aml-build.c (e2ea299b01fbd9d4d0262cfbfcbdbd02ada984a5) | aml-build.c (6ece7053d6a4a502d2ea5d24ecf512caaa1437c7) |
---|---|
1/* Support for generating ACPI tables and passing them to Guests 2 * 3 * Copyright (C) 2015 Red Hat Inc 4 * 5 * Author: Michael S. Tsirkin <mst@redhat.com> 6 * Author: Igor Mammedov <imammedo@redhat.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 690 unchanged lines hidden (view full) --- 699 Hex2Digit(str[4]) << 8 | 700 Hex2Digit(str[5]) << 4 | 701 Hex2Digit(str[6]); 702 703 build_append_byte(var->buf, 0x0C); /* DWordPrefix */ 704 build_append_int_noprefix(var->buf, bswap32(id), sizeof(id)); 705 return var; 706} | 1/* Support for generating ACPI tables and passing them to Guests 2 * 3 * Copyright (C) 2015 Red Hat Inc 4 * 5 * Author: Michael S. Tsirkin <mst@redhat.com> 6 * Author: Igor Mammedov <imammedo@redhat.com> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 690 unchanged lines hidden (view full) --- 699 Hex2Digit(str[4]) << 8 | 700 Hex2Digit(str[5]) << 4 | 701 Hex2Digit(str[6]); 702 703 build_append_byte(var->buf, 0x0C); /* DWordPrefix */ 704 build_append_int_noprefix(var->buf, bswap32(id), sizeof(id)); 705 return var; 706} |
707 708/* ACPI 1.0b: 6.4.3.5.5 Word Address Space Descriptor: bytes 3-5 */ 709static Aml *aml_as_desc_header(AmlResourceType type, AmlMinFixed min_fixed, 710 AmlMaxFixed max_fixed, AmlDecode dec, 711 uint8_t type_flags) 712{ 713 uint8_t flags = max_fixed | min_fixed | dec; 714 Aml *var = aml_alloc(); 715 716 build_append_byte(var->buf, type); 717 build_append_byte(var->buf, flags); 718 build_append_byte(var->buf, type_flags); /* Type Specific Flags */ 719 return var; 720} 721 722/* ACPI 1.0b: 6.4.3.5.5 Word Address Space Descriptor */ 723static Aml *aml_word_as_desc(AmlResourceType type, AmlMinFixed min_fixed, 724 AmlMaxFixed max_fixed, AmlDecode dec, 725 uint16_t addr_gran, uint16_t addr_min, 726 uint16_t addr_max, uint16_t addr_trans, 727 uint16_t len, uint8_t type_flags) 728{ 729 Aml *var = aml_alloc(); 730 731 build_append_byte(var->buf, 0x88); /* Word Address Space Descriptor */ 732 /* minimum length since we do not encode optional fields */ 733 build_append_byte(var->buf, 0x0D); 734 build_append_byte(var->buf, 0x0); 735 736 aml_append(var, 737 aml_as_desc_header(type, min_fixed, max_fixed, dec, type_flags)); 738 build_append_int_noprefix(var->buf, addr_gran, sizeof(addr_gran)); 739 build_append_int_noprefix(var->buf, addr_min, sizeof(addr_min)); 740 build_append_int_noprefix(var->buf, addr_max, sizeof(addr_max)); 741 build_append_int_noprefix(var->buf, addr_trans, sizeof(addr_trans)); 742 build_append_int_noprefix(var->buf, len, sizeof(len)); 743 return var; 744} 745 746/* ACPI 1.0b: 6.4.3.5.3 DWord Address Space Descriptor */ 747static Aml *aml_dword_as_desc(AmlResourceType type, AmlMinFixed min_fixed, 748 AmlMaxFixed max_fixed, AmlDecode dec, 749 uint32_t addr_gran, uint32_t addr_min, 750 uint32_t addr_max, uint32_t addr_trans, 751 uint32_t len, uint8_t type_flags) 752{ 753 Aml *var = aml_alloc(); 754 755 build_append_byte(var->buf, 0x87); /* DWord Address Space Descriptor */ 756 /* minimum length since we do not encode optional fields */ 757 build_append_byte(var->buf, 23); 758 build_append_byte(var->buf, 0x0); 759 760 761 aml_append(var, 762 aml_as_desc_header(type, min_fixed, max_fixed, dec, type_flags)); 763 build_append_int_noprefix(var->buf, addr_gran, sizeof(addr_gran)); 764 build_append_int_noprefix(var->buf, addr_min, sizeof(addr_min)); 765 build_append_int_noprefix(var->buf, addr_max, sizeof(addr_max)); 766 build_append_int_noprefix(var->buf, addr_trans, sizeof(addr_trans)); 767 build_append_int_noprefix(var->buf, len, sizeof(len)); 768 return var; 769} 770 771/* ACPI 1.0b: 6.4.3.5.1 QWord Address Space Descriptor */ 772static Aml *aml_qword_as_desc(AmlResourceType type, AmlMinFixed min_fixed, 773 AmlMaxFixed max_fixed, AmlDecode dec, 774 uint64_t addr_gran, uint64_t addr_min, 775 uint64_t addr_max, uint64_t addr_trans, 776 uint64_t len, uint8_t type_flags) 777{ 778 Aml *var = aml_alloc(); 779 780 build_append_byte(var->buf, 0x8A); /* QWord Address Space Descriptor */ 781 /* minimum length since we do not encode optional fields */ 782 build_append_byte(var->buf, 0x2B); 783 build_append_byte(var->buf, 0x0); 784 785 aml_append(var, 786 aml_as_desc_header(type, min_fixed, max_fixed, dec, type_flags)); 787 build_append_int_noprefix(var->buf, addr_gran, sizeof(addr_gran)); 788 build_append_int_noprefix(var->buf, addr_min, sizeof(addr_min)); 789 build_append_int_noprefix(var->buf, addr_max, sizeof(addr_max)); 790 build_append_int_noprefix(var->buf, addr_trans, sizeof(addr_trans)); 791 build_append_int_noprefix(var->buf, len, sizeof(len)); 792 return var; 793} 794 795/* 796 * ACPI 1.0b: 6.4.3.5.6 ASL Macros for WORD Address Descriptor 797 * 798 * More verbose description at: 799 * ACPI 5.0: 19.5.141 WordBusNumber (Word Bus Number Resource Descriptor Macro) 800 */ 801Aml *aml_word_bus_number(AmlMinFixed min_fixed, AmlMaxFixed max_fixed, 802 AmlDecode dec, uint16_t addr_gran, 803 uint16_t addr_min, uint16_t addr_max, 804 uint16_t addr_trans, uint16_t len) 805 806{ 807 return aml_word_as_desc(aml_bus_number_range, min_fixed, max_fixed, dec, 808 addr_gran, addr_min, addr_max, addr_trans, len, 0); 809} 810 811/* 812 * ACPI 1.0b: 6.4.3.5.6 ASL Macros for WORD Address Descriptor 813 * 814 * More verbose description at: 815 * ACPI 5.0: 19.5.142 WordIO (Word IO Resource Descriptor Macro) 816 */ 817Aml *aml_word_io(AmlMinFixed min_fixed, AmlMaxFixed max_fixed, 818 AmlDecode dec, AmlISARanges isa_ranges, 819 uint16_t addr_gran, uint16_t addr_min, 820 uint16_t addr_max, uint16_t addr_trans, 821 uint16_t len) 822 823{ 824 return aml_word_as_desc(aml_io_range, min_fixed, max_fixed, dec, 825 addr_gran, addr_min, addr_max, addr_trans, len, 826 isa_ranges); 827} 828 829/* 830 * ACPI 1.0b: 6.4.3.5.4 ASL Macros for DWORD Address Space Descriptor 831 * 832 * More verbose description at: 833 * ACPI 5.0: 19.5.34 DWordMemory (DWord Memory Resource Descriptor Macro) 834 */ 835Aml *aml_dword_memory(AmlDecode dec, AmlMinFixed min_fixed, 836 AmlMaxFixed max_fixed, AmlCacheble cacheable, 837 AmlReadAndWrite read_and_write, 838 uint32_t addr_gran, uint32_t addr_min, 839 uint32_t addr_max, uint32_t addr_trans, 840 uint32_t len) 841{ 842 uint8_t flags = read_and_write | (cacheable << 1); 843 844 return aml_dword_as_desc(aml_memory_range, min_fixed, max_fixed, 845 dec, addr_gran, addr_min, addr_max, 846 addr_trans, len, flags); 847} 848 849/* 850 * ACPI 1.0b: 6.4.3.5.2 ASL Macros for QWORD Address Space Descriptor 851 * 852 * More verbose description at: 853 * ACPI 5.0: 19.5.102 QWordMemory (QWord Memory Resource Descriptor Macro) 854 */ 855Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, 856 AmlMaxFixed max_fixed, AmlCacheble cacheable, 857 AmlReadAndWrite read_and_write, 858 uint64_t addr_gran, uint64_t addr_min, 859 uint64_t addr_max, uint64_t addr_trans, 860 uint64_t len) 861{ 862 uint8_t flags = read_and_write | (cacheable << 1); 863 864 return aml_qword_as_desc(aml_memory_range, min_fixed, max_fixed, 865 dec, addr_gran, addr_min, addr_max, 866 addr_trans, len, flags); 867} |
|