Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/net/aienos_virtio_pci.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / net / aienos_virtio_pci.h` 58 lines ยท 1947 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* Pure parsing of virtio 1.x PCI vendor capabilities from a PCI configuration 18 * image. Port of crates/aienos-kernel/src/virtio_net.rs (the spec). No device 19 * access, no heap. Error order matches the Rust reference. */ 20 #ifndef AIENOS_VIRTIO_PCI_H 21 #define AIENOS_VIRTIO_PCI_H 22 23 #include 24 #include 25 26 typedef enum { 27 VIRTIO_PCI_OK = 0, 28 VIRTIO_PCI_INVALID_CONFIG_LENGTH = 1, 29 VIRTIO_PCI_CAPABILITIES_NOT_PRESENT = 2, 30 VIRTIO_PCI_INVALID_POINTER = 3, 31 VIRTIO_PCI_CAPABILITY_LOOP = 4, 32 VIRTIO_PCI_SHORT_CAPABILITY = 5, 33 VIRTIO_PCI_INVALID_REGION = 6, 34 VIRTIO_PCI_DUPLICATE_CAPABILITY = 7, 35 } virtio_pci_err; 36 37 typedef struct { 38 uint8_t present; 39 uint8_t bar; 40 uint32_t offset; 41 uint32_t length; 42 } virtio_pci_region; 43 44 typedef struct { 45 virtio_pci_region common_cfg; 46 virtio_pci_region notify_cfg; 47 uint8_t has_notify_off_multiplier; 48 uint32_t notify_off_multiplier; 49 virtio_pci_region isr_cfg; 50 virtio_pci_region device_cfg; 51 } virtio_pci_caps; 52 53 /* config must be exactly 256 or 4096 bytes. *out is zeroed first and is only 54 * meaningful when VIRTIO_PCI_OK is returned. */ 55 virtio_pci_err virtio_pci_parse_caps(const uint8_t *config, size_t len, virtio_pci_caps *out); 56 const char *virtio_pci_err_name(virtio_pci_err e); 57 58 #endif