opuntiaOS - an operating system targeting x86 and ARMv7
at master 1.6 kB view raw
1/* 2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors. 3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com> 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#ifndef _KERNEL_DRIVERS_BITS_DEVICE_H 10#define _KERNEL_DRIVERS_BITS_DEVICE_H 11 12#include <libkern/types.h> 13 14enum DEVICES_TYPE { 15 DEVICE_STORAGE = (1 << 0), 16 DEVICE_SOUND = (1 << 1), 17 DEVICE_INPUT_SYSTEMS = (1 << 2), 18 DEVICE_NETWORK = (1 << 3), 19 DEVICE_DISPLAY = (1 << 4), 20 DEVICE_BUS_CONTROLLER = (1 << 5), 21 DEVICE_BRIDGE = (1 << 6), 22 DEVICE_CHAR = (1 << 7), 23 DEVICE_UNKNOWN = (1 << 8), 24}; 25 26enum DEVICE_DESC_TYPE { 27 DEVICE_DESC_PCI, 28 DEVICE_DESC_DEVTREE, 29}; 30 31struct device_desc_pci { 32 uint8_t bus; 33 uint8_t device; 34 uint8_t function; 35 uint16_t vendor_id; 36 uint16_t device_id; 37 uint8_t class_id; 38 uint8_t subclass_id; 39 uint8_t interface_id; 40 uint8_t revision_id; 41 uint32_t interrupt; 42 uint32_t port_base; 43}; 44typedef struct device_desc_pci device_desc_pci_t; 45 46struct devtree_entry; 47struct device_desc_devtree { 48 struct devtree_entry* entry; 49}; 50typedef struct device_desc_devtree device_desc_devtree_t; 51 52struct device_desc { 53 int type; 54 union { 55 device_desc_pci_t pci; 56 device_desc_devtree_t devtree; 57 }; 58 uint32_t args[4]; 59}; 60typedef struct device_desc device_desc_t; 61 62#define DRIVER_ID_EMPTY (0xff) 63struct device { 64 int id; 65 int type; 66 bool is_virtual; 67 int driver_id; 68 device_desc_t device_desc; 69}; 70typedef struct device device_t; 71 72#endif // _KERNEL_DRIVERS_BITS_DEVICE_H