要するに:
x86_64 仮想マシン内で sel4 マイクロカーネルを実行しようとしていますが、イーサネット インターフェイスが機能しません。sel4 マイクロカーネルで (vitio-net イーサネット デバイス経由で) インターネット接続を取得するための正しい手順は何ですか? そして、正しい(メモリ)アドレスは何ですか?
長いバージョン:
e1000 ネットデバイスで camkes (picoserver) の例を試してみましたが、うまく動かなかったので、いくつか新しいことを学び、ゼロから始めることにしました。また、パフォーマンスを向上させるために、エミュレートされた e1000 デバイスの代わりに virtio-net (vhost と一緒に) を使用することにしました。私の計画は、構造体ethif_virtio_pci_init
を初期化してeth_driver
から、その構造体を picoTCP に渡すために使用することです。今のところ、sel4 で virtio PCI デバイスを見つけることができますが、正しくアクセスしてethif_virtio_pci_config_t
必要な を作成する方法がわかりませんethif_virtio_pci_init
。
libethdrivers virtio_pci.h からの情報:
typedef struct ethif_virtio_pci_config {
uint16_t io_base;
void *mmio_base;
} ethif_virtio_pci_config_t;
/**
* This function initialises the hardware and conforms to the ethif_driver_init
* type in raw.h
* @param[out] eth_driver Ethernet driver structure to fill out
* @param[in] io_ops A structure containing os specific data and
* functions.
* @param[in] config Pointer to a ethif_virtio_pci_config struct
*/
int ethif_virtio_pci_init(struct eth_driver *eth_driver, ps_io_ops_t io_ops, void *config);
そのため、ethif_virtio_pci_config_t
uint16_t io_base アドレスと MMIO ベースへのポインターが必要です。
これは私がこれまでに得た情報です:
Found virtio_net_pci device
BASE_ADDR[0] ----
base_addr_space[0]: 0x1 [PCI_BASE_ADDRESS_SPACE_IO]
base_addr_type[0]: 0x0 [ 32bit ]
base_addr_prefetchable[0]: no
base_addr[0]: 0xc000
base_addr_size_mask[0]: 0xffffffe0
BASE_ADDR[1] ----
base_addr_space[1]: 0x0 [PCI_BASE_ADDRESS_SPACE_MEMORY]
base_addr_type[1]: 0x0 [ 32bit ]
base_addr_prefetchable[1]: no
base_addr[1]: 0xfeb91000
base_addr_size_mask[1]: 0xfffff000
BASE_ADDR[2] ----
BASE_ADDR[3] ----
BASE_ADDR[4] ----
base_addr_space[4]: 0x0 [PCI_BASE_ADDRESS_SPACE_MEMORY]
base_addr_type[4]: 0x4 [ 64bit ]
base_addr_prefetchable[4]: yes
base_addr[4]: 0xfe000000
base_addr_size_mask[4]: 0xffffc000
BASE_ADDR[5] ----
私が理解している限り、物理アドレスを仮想アドレスにマップする必要があります。そのために、IO-mapper を作成しましたが、何をマップすればよいかわかりません。0x8000000 から始まる dma 領域全体ですか、それとも virtio デバイスのアドレスだけですか? 私が理解している限り、新しい仮想アドレスは MMIO ベース ポインターになりますが、uint16_t io_base とは何ですか?
これはこれまでの私のコードです。不明な部分は最後にあります。
#define ALLOCATOR_STATIC_POOL_SIZE ((1 << seL4_LargePageBits) * 10)
static simple_t simple;
static ps_io_mapper_t io_mapper;
static char allocator_mem_pool[ALLOCATOR_STATIC_POOL_SIZE];
static vka_t vka;
static vspace_t vspace;
static sel4utils_alloc_data_t data;
static ltimer_t timer;
int main() {
PRINT_DBG("Hello World\n");
seL4_BootInfo *info = platsupport_get_bootinfo();
simple_default_init_bootinfo(&simple, info);
/* print out bootinfo and other info about simple */
// simple_print(&simple);
allocman_t *allocman = bootstrap_use_current_simple(&simple, ALLOCATOR_STATIC_POOL_SIZE, allocator_mem_pool);
if (allocman == NULL) {
ZF_LOGF("Failed to create allocman");
}
allocman_make_vka(&vka, allocman);
int error = sel4utils_bootstrap_vspace_with_bootinfo_leaky(&vspace,
&data, simple_get_pd(&simple),
&vka, info);
if (error != 0) {
PRINT_DBG("Failed to create virtual memory manager. Error: %d\n", error);
return -1;
}
error = sel4platsupport_new_io_mapper(&vspace, &vka, &io_mapper);
if (error != 0) {
PRINT_DBG("Failed to create io mapper. Error: %d\n", error);
return -1;
}
ps_io_ops_t io_ops;
error = sel4platsupport_new_io_ops(&vspace, &vka, &simple, &io_ops);
if (error != 0) {
PRINT_DBG("Failed to create io ops. Error: %d\n", error);
return -1;
}
ps_io_port_ops_t port_ops;
int error = sel4platsupport_get_io_port_ops(&port_ops, &simple, &vka);
if (error != 0) {
PRINT_DBG("Failed to find io port ops. Error: %d\n", error);
return -1;
}
printf("Start scannning\n");
libpci_scan(port_ops);
PRINT_DBG("Found %u devices\n", libpci_num_devices);
for (uint32_t i = 0; i < libpci_num_devices; ++i) {
PRINT_DBG("PCI device %u. Vendor id: %x. Device id: %x\n",
i, libpci_device_list[i].vendor_id, libpci_device_list[i].device_id);
}
libpci_device_t* virtio_net_pci = libpci_find_device(0x1af4, 0x1000);
if (!virtio_net_pci) {
PRINT_DBG("Failed to find the virtio_net_pci device\n");
// return -1;
}else{
// libpci_device_iocfg_debug_print(&virtio_net_pci->cfg,true);
PRINT_DBG("Found virtio_net_pci device\n");
libpci_device_iocfg_debug_print(&virtio_net_pci->cfg,false);
}
//Now what?
unsigned long phys = 0x8000000; //what physical address to map?
void *mmio_ptr = ps_io_map(&io_mapper, phys, 4096, 0, PS_MEM_NORMAL);
memset(ptr, 0, 4096);
if (mmio_ptr == NULL) {
PRINT_DBG("Failed to map phys addr. Error: %p\n", ptr);
return -1;
}
ethif_virtio_pci_config_t me_config;
me_config.mmio_base = mmio_ptr; //is this correct?
//me_config.io_base = ?
私は sel4 カーネルについて多くのことを読みましたが、sel4 マイクロカーネル (および Linux カーネル) のほとんどの概念についてはまだ初心者なので、ヒントや推奨事項があれば非常に感謝しています。私は通常、組み込み、マイクロコントローラー、およびより多くの「ベアメタル」プラットフォームで作業しており、何か新しいことを学びたいと思っていましたが、今のところ多くのことが非常に混乱しています.