Changeset 100716 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jul 27, 2023 12:15:05 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImplConfigArmV8.cpp
r100707 r100716 145 145 uint64_t const cbRam = cRamMBs * (uint64_t)_1M; 146 146 147 /** @todo This will be 100% wrong but is required for getting the maximum number of network adapters. */ 148 ChipsetType_T chipsetType; 149 hrc = pMachine->COMGETTER(ChipsetType)(&chipsetType); H(); 150 147 151 ULONG cCpus = 1; 148 152 hrc = pMachine->COMGETTER(CPUCount)(&cCpus); H(); … … 154 158 hrc = pMachine->COMGETTER(OSTypeId)(osTypeId.asOutParam()); H(); 155 159 LogRel(("Guest OS type: '%s'\n", Utf8Str(osTypeId).c_str())); 160 161 ULONG maxNetworkAdapters; 162 hrc = systemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters); H(); 156 163 157 164 /* … … 406 413 PCFGMNODE pLunL0 = NULL; /* /Devices/Dev/0/LUN#0/ */ 407 414 PCFGMNODE pLunL1 = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/ */ 408 PCFGMNODE pLunL1Cfg = NULL; /* /Devices/Dev/0/LUN#0/AttachedDriver/Config */409 415 410 416 InsertConfigNode(pRoot, "Devices", &pDevices); … … 753 759 InsertConfigString(pLunL0, "Driver","VUSBRootHub"); 754 760 755 #if 0 756 InsertConfigNode(pDevices, "e1000", &pDev); 757 InsertConfigNode(pDev, "0", &pInst); 758 InsertConfigInteger(pInst, "Trusted", 1); 759 InsertConfigInteger(pInst, "PCIBusNo", 0); 760 InsertConfigInteger(pInst, "PCIDeviceNo", 2); 761 InsertConfigInteger(pInst, "PCIFunctionNo", 0); 762 InsertConfigNode(pInst, "Config", &pCfg); 763 InsertConfigInteger(pCfg, "CableConnected", 1); 764 InsertConfigInteger(pCfg, "LineSpeed", 0); 765 InsertConfigInteger(pCfg, "AdapterType", 0); 766 #else 767 InsertConfigNode(pDevices, "virtio-net", &pDev); 768 InsertConfigNode(pDev, "0", &pInst); 769 InsertConfigInteger(pInst, "Trusted", 1); 770 InsertConfigNode(pInst, "Config", &pCfg); 771 InsertConfigInteger(pCfg, "CableConnected", 1); 772 InsertConfigInteger(pCfg, "MmioBase", 0x0a000000); 773 InsertConfigInteger(pCfg, "Irq", 16); 774 775 vrc = RTFdtNodeAddF(hFdt, "virtio_mmio@%RX32", 0x0a000000); VRC(); 776 vrc = RTFdtNodePropertyAddEmpty( hFdt, "dma-coherent"); VRC(); 777 vrc = RTFdtNodePropertyAddCellsU32(hFdt, "interrupts", 3, 0x00, 16, 0x04); VRC(); 778 vrc = RTFdtNodePropertyAddCellsU32(hFdt, "reg", 4, 0, 0x0a000000, 0, 0x200); VRC(); 779 vrc = RTFdtNodePropertyAddString(hFdt, "compatible", "virtio,mmio"); VRC(); 780 vrc = RTFdtNodeFinalize(hFdt); VRC(); 761 /* 762 * Network adapters 763 */ 764 PCFGMNODE pDevE1000 = NULL; /* E1000-type devices */ 765 InsertConfigNode(pDevices, "e1000", &pDevE1000); 766 PCFGMNODE pDevVirtioNet = NULL; /* Virtio network devices */ 767 InsertConfigNode(pDevices, "virtio-net", &pDevVirtioNet); 768 769 for (ULONG uInstance = 0; uInstance < maxNetworkAdapters; ++uInstance) 770 { 771 ComPtr<INetworkAdapter> networkAdapter; 772 hrc = pMachine->GetNetworkAdapter(uInstance, networkAdapter.asOutParam()); H(); 773 BOOL fEnabledNetAdapter = FALSE; 774 hrc = networkAdapter->COMGETTER(Enabled)(&fEnabledNetAdapter); H(); 775 if (!fEnabledNetAdapter) 776 continue; 777 778 /* 779 * The virtual hardware type. Create appropriate device first. 780 */ 781 const char *pszAdapterName = "pcnet"; 782 NetworkAdapterType_T adapterType; 783 hrc = networkAdapter->COMGETTER(AdapterType)(&adapterType); H(); 784 switch (adapterType) 785 { 786 #ifdef VBOX_WITH_E1000 787 case NetworkAdapterType_I82540EM: 788 case NetworkAdapterType_I82543GC: 789 case NetworkAdapterType_I82545EM: 790 pDev = pDevE1000; 791 pszAdapterName = "e1000"; 792 break; 781 793 #endif 782 783 const char *pszMac = "080027ede92c"; 784 Assert(strlen(pszMac) == 12); 785 RTMAC Mac; 786 RT_ZERO(Mac); 787 char *pMac = (char*)&Mac; 788 for (uint32_t i = 0; i < 6; ++i) 789 { 790 int c1 = *pszMac++ - '0'; 791 if (c1 > 9) 792 c1 -= 7; 793 int c2 = *pszMac++ - '0'; 794 if (c2 > 9) 795 c2 -= 7; 796 *pMac++ = (char)(((c1 & 0x0f) << 4) | (c2 & 0x0f)); 794 #ifdef VBOX_WITH_VIRTIO 795 case NetworkAdapterType_Virtio: 796 pDev = pDevVirtioNet; 797 pszAdapterName = "virtio-net"; 798 break; 799 #endif /* VBOX_WITH_VIRTIO */ 800 case NetworkAdapterType_Am79C970A: 801 case NetworkAdapterType_Am79C973: 802 case NetworkAdapterType_Am79C960: 803 case NetworkAdapterType_NE1000: 804 case NetworkAdapterType_NE2000: 805 case NetworkAdapterType_WD8003: 806 case NetworkAdapterType_WD8013: 807 case NetworkAdapterType_ELNK2: 808 case NetworkAdapterType_ELNK1: 809 default: 810 AssertMsgFailed(("Invalid/Unsupported network adapter type '%d' for slot '%d'", adapterType, uInstance)); 811 return pVMM->pfnVMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, 812 N_("Invalid/Unsupported network adapter type '%d' for slot '%d'"), adapterType, uInstance); 813 } 814 815 InsertConfigNode(pDev, Utf8StrFmt("%u", uInstance).c_str(), &pInst); 816 InsertConfigInteger(pInst, "Trusted", 1); /* boolean */ 817 /* the first network card gets the PCI ID 3, the next 3 gets 8..10, 818 * next 4 get 16..19. */ 819 int iPCIDeviceNo; 820 switch (uInstance) 821 { 822 case 0: 823 iPCIDeviceNo = 3; 824 break; 825 case 1: case 2: case 3: 826 iPCIDeviceNo = uInstance - 1 + 8; 827 break; 828 case 4: case 5: case 6: case 7: 829 iPCIDeviceNo = uInstance - 4 + 16; 830 break; 831 default: 832 /* auto assignment */ 833 iPCIDeviceNo = -1; 834 break; 835 } 836 837 InsertConfigNode(pInst, "Config", &pCfg); 838 839 /* 840 * The virtual hardware type. PCNet supports three types, E1000 three, 841 * but VirtIO only one. 842 */ 843 switch (adapterType) 844 { 845 case NetworkAdapterType_Am79C970A: 846 InsertConfigString(pCfg, "ChipType", "Am79C970A"); 847 break; 848 case NetworkAdapterType_Am79C973: 849 InsertConfigString(pCfg, "ChipType", "Am79C973"); 850 break; 851 case NetworkAdapterType_Am79C960: 852 InsertConfigString(pCfg, "ChipType", "Am79C960"); 853 break; 854 case NetworkAdapterType_I82540EM: 855 InsertConfigInteger(pCfg, "AdapterType", 0); 856 break; 857 case NetworkAdapterType_I82543GC: 858 InsertConfigInteger(pCfg, "AdapterType", 1); 859 break; 860 case NetworkAdapterType_I82545EM: 861 InsertConfigInteger(pCfg, "AdapterType", 2); 862 break; 863 case NetworkAdapterType_Virtio: 864 { 865 uint32_t GCPhysMmioBase = 0x0a000000 + uInstance * 512; 866 uint32_t uIrq = 16 + uInstance; 867 868 InsertConfigInteger(pCfg, "MmioBase", GCPhysMmioBase); 869 InsertConfigInteger(pCfg, "Irq", uIrq); 870 871 vrc = RTFdtNodeAddF(hFdt, "virtio_mmio@%RX32", 0x0a000000); VRC(); 872 vrc = RTFdtNodePropertyAddEmpty( hFdt, "dma-coherent"); VRC(); 873 vrc = RTFdtNodePropertyAddCellsU32(hFdt, "interrupts", 3, 0x00, uIrq, 0x04); VRC(); 874 vrc = RTFdtNodePropertyAddCellsU32(hFdt, "reg", 4, 0, GCPhysMmioBase, 0, 0x200); VRC(); 875 vrc = RTFdtNodePropertyAddString(hFdt, "compatible", "virtio,mmio"); VRC(); 876 vrc = RTFdtNodeFinalize(hFdt); VRC(); 877 break; 878 } 879 case NetworkAdapterType_NE1000: 880 InsertConfigString(pCfg, "DeviceType", "NE1000"); 881 break; 882 case NetworkAdapterType_NE2000: 883 InsertConfigString(pCfg, "DeviceType", "NE2000"); 884 break; 885 case NetworkAdapterType_WD8003: 886 InsertConfigString(pCfg, "DeviceType", "WD8003"); 887 break; 888 case NetworkAdapterType_WD8013: 889 InsertConfigString(pCfg, "DeviceType", "WD8013"); 890 break; 891 case NetworkAdapterType_ELNK2: 892 InsertConfigString(pCfg, "DeviceType", "3C503"); 893 break; 894 case NetworkAdapterType_ELNK1: 895 break; 896 case NetworkAdapterType_Null: AssertFailedBreak(); /* (compiler warnings) */ 897 #ifdef VBOX_WITH_XPCOM_CPP_ENUM_HACK 898 case NetworkAdapterType_32BitHack: AssertFailedBreak(); /* (compiler warnings) */ 899 #endif 900 } 901 902 /* 903 * Get the MAC address and convert it to binary representation 904 */ 905 Bstr macAddr; 906 hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam()); H(); 907 Assert(!macAddr.isEmpty()); 908 Utf8Str macAddrUtf8 = macAddr; 909 #ifdef VBOX_WITH_CLOUD_NET 910 NetworkAttachmentType_T eAttachmentType; 911 hrc = networkAdapter->COMGETTER(AttachmentType)(&eAttachmentType); H(); 912 if (eAttachmentType == NetworkAttachmentType_Cloud) 913 { 914 mGateway.setLocalMacAddress(macAddrUtf8); 915 /* We'll insert cloud MAC later, when it becomes known. */ 916 } 917 else 918 { 919 #endif 920 char *macStr = (char*)macAddrUtf8.c_str(); 921 Assert(strlen(macStr) == 12); 922 RTMAC Mac; 923 RT_ZERO(Mac); 924 char *pMac = (char*)&Mac; 925 for (uint32_t i = 0; i < 6; ++i) 926 { 927 int c1 = *macStr++ - '0'; 928 if (c1 > 9) 929 c1 -= 7; 930 int c2 = *macStr++ - '0'; 931 if (c2 > 9) 932 c2 -= 7; 933 *pMac++ = (char)(((c1 & 0x0f) << 4) | (c2 & 0x0f)); 934 } 935 InsertConfigBytes(pCfg, "MAC", &Mac, sizeof(Mac)); 936 #ifdef VBOX_WITH_CLOUD_NET 937 } 938 #endif 939 /* 940 * Check if the cable is supposed to be unplugged 941 */ 942 BOOL fCableConnected; 943 hrc = networkAdapter->COMGETTER(CableConnected)(&fCableConnected); H(); 944 InsertConfigInteger(pCfg, "CableConnected", fCableConnected ? 1 : 0); 945 946 /* 947 * Line speed to report from custom drivers 948 */ 949 ULONG ulLineSpeed; 950 hrc = networkAdapter->COMGETTER(LineSpeed)(&ulLineSpeed); H(); 951 InsertConfigInteger(pCfg, "LineSpeed", ulLineSpeed); 952 953 /* 954 * Attach the status driver. 955 */ 956 i_attachStatusDriver(pInst, DeviceType_Network); 957 958 /* 959 * Configure the network card now 960 */ 961 bool fIgnoreConnectFailure = mMachineState == MachineState_Restoring; 962 vrc = i_configNetwork(pszAdapterName, 963 uInstance, 964 0, 965 networkAdapter, 966 pCfg, 967 pLunL0, 968 pInst, 969 false /*fAttachDetach*/, 970 fIgnoreConnectFailure, 971 pUVM, 972 pVMM); 973 if (RT_FAILURE(vrc)) 974 return vrc; 797 975 } 798 InsertConfigBytes(pCfg, "MAC", &Mac, sizeof(Mac));799 InsertConfigNode(pInst, "LUN#0", &pLunL0);800 InsertConfigString(pLunL0, "Driver", "NAT");801 InsertConfigNode(pLunL0, "Config", &pLunL1Cfg);802 InsertConfigString(pLunL1Cfg, "Network", "10.0.2.0/24");803 InsertConfigString(pLunL1Cfg, "TFTPPrefix", "/Users/vbox/Library/VirtualBox/TFTP");804 InsertConfigString(pLunL1Cfg, "BootFile", "default.pxe");805 InsertConfigInteger(pLunL1Cfg, "AliasMode", 0);806 InsertConfigInteger(pLunL1Cfg, "DNSProxy", 0);807 InsertConfigInteger(pLunL1Cfg, "LocalhostReachable", 1);808 InsertConfigInteger(pLunL1Cfg, "PassDomain", 1);809 InsertConfigInteger(pLunL1Cfg, "UseHostResolver", 0);810 976 811 977 PCFGMNODE pUsb = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.