Annotation of qemu/roms/SLOF/lib/libvirtio/virtio.h, revision 1.1.1.1

1.1       root        1: /******************************************************************************
                      2:  * Copyright (c) 2011 IBM Corporation
                      3:  * All rights reserved.
                      4:  * This program and the accompanying materials
                      5:  * are made available under the terms of the BSD License
                      6:  * which accompanies this distribution, and is available at
                      7:  * http://www.opensource.org/licenses/bsd-license.php
                      8:  *
                      9:  * Contributors:
                     10:  *     IBM Corporation - initial implementation
                     11:  *****************************************************************************/
                     12: 
                     13: #ifndef _LIBVIRTIO_H
                     14: #define _LIBVIRTIO_H
                     15: 
                     16: #include <stdint.h>
                     17: 
                     18: /* Device status bits */
                     19: #define VIRTIO_STAT_ACKNOWLEDGE                1
                     20: #define VIRTIO_STAT_DRIVER             2
                     21: #define VIRTIO_STAT_DRIVER_OK          4
                     22: #define VIRTIO_STAT_FAILED             128
                     23: 
                     24: /* Definitions for vring_desc.flags */
                     25: #define VRING_DESC_F_NEXT      1       /* buffer continues via the next field */
                     26: #define VRING_DESC_F_WRITE     2       /* buffer is write-only (otherwise read-only) */
                     27: #define VRING_DESC_F_INDIRECT  4       /* buffer contains a list of buffer descriptors */
                     28: 
                     29: /* Descriptor table entry - see Virtio Spec chapter 2.3.2 */
                     30: struct vring_desc {
                     31:        uint64_t addr;          /* Address (guest-physical) */
                     32:        uint32_t len;           /* Length */
                     33:        uint16_t flags;         /* The flags as indicated above */
                     34:        uint16_t next;          /* Next field if flags & NEXT */
                     35: }; 
                     36: 
                     37: /* Definitions for vring_avail.flags */
                     38: #define VRING_AVAIL_F_NO_INTERRUPT     1
                     39: 
                     40: /* Available ring - see Virtio Spec chapter 2.3.4 */
                     41: struct vring_avail {
                     42:        uint16_t flags;
                     43:        uint16_t idx;
                     44:        uint16_t ring[];
                     45: }; 
                     46: 
                     47: 
                     48: /* Definitions for vring_used.flags */
                     49: #define VRING_USED_F_NO_NOTIFY         1
                     50: 
                     51: struct vring_used_elem {
                     52:        uint32_t id;            /* Index of start of used descriptor chain */
                     53:        uint32_t len;           /* Total length of the descriptor chain which was used */
                     54: };
                     55: 
                     56: struct vring_used {
                     57:        uint16_t flags;
                     58:        uint16_t idx;
                     59:        struct vring_used_elem ring[];
                     60: };
                     61: 
                     62: #define VIRTIO_TYPE_PCI 0      /* For virtio-pci interface */
                     63: struct virtio_device {
                     64:        void *base;             /* base address */
                     65:        int type;               /* VIRTIO_TYPE_PCI or VIRTIO_TYPE_VIO */
                     66: };
                     67: 
                     68: /* Parts of the virtqueue are aligned on a 4096 byte page boundary */
                     69: #define VQ_ALIGN(addr) (((addr) + 0xfff) & ~0xfff)
                     70: 
                     71: extern unsigned long virtio_vring_size(unsigned int qsize);
                     72: extern int virtio_get_qsize(struct virtio_device *dev, int queue);
                     73: extern struct vring_desc *virtio_get_vring_desc(struct virtio_device *dev, int queue);
                     74: extern struct vring_avail *virtio_get_vring_avail(struct virtio_device *dev, int queue);
                     75: extern struct vring_used *virtio_get_vring_used(struct virtio_device *dev, int queue);
                     76: 
                     77: extern void virtio_reset_device(struct virtio_device *dev);
                     78: extern void virtio_queue_notify(struct virtio_device *dev, int queue);
                     79: extern void virtio_set_status(struct virtio_device *dev, int status);
                     80: extern void virtio_set_guest_features(struct virtio_device *dev, int features);
                     81: extern uint64_t virtio_get_config(struct virtio_device *dev, int offset, int size);
                     82: extern int __virtio_read_config(struct virtio_device *dev, void *dst,
                     83:                                int offset, int len);
                     84: 
                     85: 
                     86: #endif /* _LIBVIRTIO_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.