Merged changes from branch build_system_redesign at revision 14573.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14574 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2005-10-29 16:27:43 +00:00
parent 5412b02d50
commit 338b8dc301
1836 changed files with 114718 additions and 14057 deletions
+122
View File
@@ -0,0 +1,122 @@
/* ACPI Bus Manger Interface
* Copyright 2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License
*/
#ifndef _ACPI_H
#define _ACPI_H
#include <bus_manager.h>
#include <KernelExport.h>
typedef struct acpi_module_info acpi_module_info;
typedef struct acpi_object_type acpi_object_type;
struct acpi_module_info {
bus_manager_info binfo;
/* Fixed Event Management */
void (*enable_fixed_event) (uint32 event);
void (*disable_fixed_event) (uint32 event);
uint32 (*fixed_event_status) (uint32 event);
/* Returns 1 if event set, 0 otherwise */
void (*reset_fixed_event) (uint32 event);
status_t (*install_fixed_event_handler) (uint32 event, interrupt_handler *handler, void *data);
status_t (*remove_fixed_event_handler) (uint32 event, interrupt_handler *handler);
/* Namespace Access */
status_t (*get_next_entry) (uint32 object_type, const char *base, char *result, size_t len, void **counter);
status_t (*get_device) (const char *hid, uint32 index, char *result);
status_t (*get_device_hid) (const char *path, char *hid);
uint32 (*get_object_type) (const char *path);
/* Control method execution and data acquisition */
status_t (*evaluate_object) (const char *object, acpi_object_type *return_value, size_t buf_len);
status_t (*evaluate_method) (const char *object, const char *method, acpi_object_type *return_value, size_t buf_len, acpi_object_type *args, int num_args);
/* Power state setting */
status_t (*enter_sleep_state) (uint8 state);
/* Sleep state values:
0: On (Working)
1: Sleep
2: Software Off
3: Mechanical Off
4: Hibernate
5: Software Off */
};
#ifndef __ACTYPES_H__
/* ACPI fixed event types */
enum {
ACPI_EVENT_PMTIMER = 0,
ACPI_EVENT_GLOBAL,
ACPI_EVENT_POWER_BUTTON,
ACPI_EVENT_SLEEP_BUTTON,
ACPI_EVENT_RTC
};
/* ACPI Object Types */
enum {
ACPI_TYPE_ANY = 0,
ACPI_TYPE_INTEGER,
ACPI_TYPE_STRING,
ACPI_TYPE_BUFFER,
ACPI_TYPE_PACKAGE,
ACPI_TYPE_FIELD_UNIT,
ACPI_TYPE_DEVICE,
ACPI_TYPE_EVENT,
ACPI_TYPE_METHOD,
ACPI_TYPE_MUTEX,
ACPI_TYPE_REGION,
ACPI_TYPE_POWER,
ACPI_TYPE_PROCESSOR,
ACPI_TYPE_THERMAL,
ACPI_TYPE_BUFFER_FIELD
};
/* ACPI control method arg type */
struct acpi_object_type {
uint32 object_type;
union {
uint32 integer;
struct {
uint32 len;
char *string; /* You have to allocate string space yourself */
} string;
struct {
size_t length;
void *buffer;
} buffer;
struct {
uint32 count;
acpi_object_type *objects;
} package;
struct {
uint32 cpu_id;
int pblk_address;
size_t pblk_length;
} processor;
struct {
uint32 min_power_state;
uint32 resource_order;
} power_resource;
} data;
};
#endif
#define B_ACPI_MODULE_NAME "bus_managers/acpi/v1"
#endif /* _ACPI_H */
+213
View File
@@ -0,0 +1,213 @@
#ifndef _DRIVERS_DRIVERS_H
#define _DRIVERS_DRIVERS_H
#include <BeBuild.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <SupportDefs.h>
#include <Select.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ---
these hooks are how the kernel accesses the device
--- */
typedef status_t (*device_open_hook) (const char *name, uint32 flags, void **cookie);
typedef status_t (*device_close_hook) (void *cookie);
typedef status_t (*device_free_hook) (void *cookie);
typedef status_t (*device_control_hook) (void *cookie, uint32 op, void *data,
size_t len);
typedef status_t (*device_read_hook) (void *cookie, off_t position, void *data,
size_t *numBytes);
typedef status_t (*device_write_hook) (void *cookie, off_t position,
const void *data, size_t *numBytes);
typedef status_t (*device_select_hook) (void *cookie, uint8 event, uint32 ref,
selectsync *sync);
typedef status_t (*device_deselect_hook) (void *cookie, uint8 event,
selectsync *sync);
typedef status_t (*device_read_pages_hook)(void *cookie, off_t position, const iovec *vec,
size_t count, size_t *_numBytes);
typedef status_t (*device_write_pages_hook) (void *cookie, off_t position, const iovec *vec,
size_t count, size_t *_numBytes);
#define B_CUR_DRIVER_API_VERSION 2
/* ---
the device_hooks structure is a descriptor for the device, giving its
entry points.
--- */
typedef struct {
device_open_hook open; /* called to open the device */
device_close_hook close; /* called to close the device */
device_free_hook free; /* called to free the cookie */
device_control_hook control; /* called to control the device */
device_read_hook read; /* reads from the device */
device_write_hook write; /* writes to the device */
device_select_hook select; /* start select */
device_deselect_hook deselect; /* stop select */
device_read_pages_hook read_pages; /* scatter-gather physical read from the device */
device_write_pages_hook write_pages; /* scatter-gather physical write to the device */
} device_hooks;
status_t init_hardware(void);
const char **publish_devices(void);
device_hooks *find_device(const char *name);
status_t init_driver(void);
void uninit_driver(void);
extern int32 api_version;
enum {
B_GET_DEVICE_SIZE = 1, /* get # bytes */
/* returns size_t in *data */
B_SET_DEVICE_SIZE, /* set # bytes */
/* passed size_t in *data */
B_SET_NONBLOCKING_IO, /* set to non-blocking i/o */
B_SET_BLOCKING_IO, /* set to blocking i/o */
B_GET_READ_STATUS, /* check if can read w/o blocking */
/* returns bool in *data */
B_GET_WRITE_STATUS, /* check if can write w/o blocking */
/* returns bool in *data */
B_GET_GEOMETRY, /* get info about device geometry */
/* returns struct geometry in *data */
B_GET_DRIVER_FOR_DEVICE, /* get the path of the executable serving that device */
B_GET_PARTITION_INFO, /* get info about a device partition */
/* returns struct partition_info in *data */
B_SET_PARTITION, /* create a user-defined partition */
B_FORMAT_DEVICE, /* low-level device format */
B_EJECT_DEVICE, /* eject the media if supported */
B_GET_ICON, /* return device icon (see struct below) */
B_GET_BIOS_GEOMETRY, /* get info about device geometry */
/* as reported by the bios */
/* returns struct geometry in *data */
B_GET_MEDIA_STATUS, /* get status of media. */
/* return status_t in *data: */
/* B_NO_ERROR: media ready */
/* B_DEV_NO_MEDIA: no media */
/* B_DEV_NOT_READY: device not ready */
/* B_DEV_MEDIA_CHANGED: media changed */
/* since open or last B_GET_MEDIA_STATUS */
/* B_DEV_MEDIA_CHANGE_REQUESTED: user */
/* pressed button on drive */
/* B_DEV_DOOR_OPEN: door open */
B_LOAD_MEDIA, /* load the media if supported */
B_GET_BIOS_DRIVE_ID, /* get bios id for this device */
B_SET_UNINTERRUPTABLE_IO, /* prevent cntl-C from interrupting i/o */
B_SET_INTERRUPTABLE_IO, /* allow cntl-C to interrupt i/o */
B_FLUSH_DRIVE_CACHE, /* flush drive cache */
B_GET_NEXT_OPEN_DEVICE = 1000, /* iterate through open devices */
B_ADD_FIXED_DRIVER, /* private */
B_REMOVE_FIXED_DRIVER, /* private */
B_AUDIO_DRIVER_BASE = 8000, /* base for codes in audio_driver.h */
B_MIDI_DRIVER_BASE = 8100, /* base for codes in midi_driver.h */
B_JOYSTICK_DRIVER_BASE = 8200, /* base for codes in joystick.h */
B_GRAPHIC_DRIVER_BASE = 8300, /* base for codes in graphic_driver.h */
B_DEVICE_OP_CODES_END = 9999 /* end of Be-defined contol id's */
};
/* ---
geometry structure for the B_GET_GEOMETRY opcode
--- */
typedef struct {
uint32 bytes_per_sector; /* sector size in bytes */
uint32 sectors_per_track; /* # sectors per track */
uint32 cylinder_count; /* # cylinders */
uint32 head_count; /* # heads */
uchar device_type; /* type */
bool removable; /* non-zero if removable */
bool read_only; /* non-zero if read only */
bool write_once; /* non-zero if write-once */
} device_geometry;
/* ---
Be-defined device types returned by B_GET_GEOMETRY. Use these if it makes
sense for your device.
--- */
enum {
B_DISK = 0, /* Hard disks, floppy disks, etc. */
B_TAPE, /* Tape drives */
B_PRINTER, /* Printers */
B_CPU, /* CPU devices */
B_WORM, /* Write-once, read-many devices */
B_CD, /* CD ROMS */
B_SCANNER, /* Scanners */
B_OPTICAL, /* Optical devices */
B_JUKEBOX, /* Jukeboxes */
B_NETWORK /* Network devices */
};
/* ---
partition_info structure used by B_GET_PARTITION_INFO and B_SET_PARTITION
--- */
typedef struct {
off_t offset; /* offset (in bytes) */
off_t size; /* size (in bytes) */
int32 logical_block_size; /* logical block size of partition */
int32 session; /* id of session */
int32 partition; /* id of partition */
char device[256]; /* path to the physical device */
} partition_info;
/* ---
driver_path structure returned by the B_GET_DRIVER_FOR_DEVICE
--- */
typedef char driver_path[256];
/* ---
open_device_iterator structure used by the B_GET_NEXT_OPEN_DEVICE opcode
--- */
typedef struct {
uint32 cookie; /* must be set to 0 before iterating */
char device[256]; /* device path */
} open_device_iterator;
/* ---
icon structure for the B_GET_ICON opcode
--- */
typedef struct {
int32 icon_size; /* icon size requested */
void *icon_data; /* where to put 'em (usually BBitmap->Bits()) */
} device_icon;
#ifdef __cplusplus
}
#endif
#endif /* _DRIVERS_DRIVERS_H */
+84
View File
@@ -0,0 +1,84 @@
/*******************************************************************************
/
/ File: ISA.h
/
/ Description: Interface to ISA module
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _ISA_H
#define _ISA_H
//#include <SupportDefs.h>
#include <bus_manager.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ---
ISA scatter/gather dma support.
--- */
typedef struct {
ulong address; /* memory address (little endian!) 4 bytes */
ushort transfer_count; /* # transfers minus one (little endian!) 2 bytes*/
uchar reserved; /* filler, 1byte*/
uchar flag; /* end of link flag, 1byte */
} isa_dma_entry;
#define B_LAST_ISA_DMA_ENTRY 0x80 /* sets end of link flag in isa_dma_entry */
enum {
B_8_BIT_TRANSFER,
B_16_BIT_TRANSFER
};
#define B_MAX_ISA_DMA_COUNT 0x10000
typedef struct isa_module_info isa_module_info;
struct isa_module_info {
bus_manager_info binfo;
uint8 (*read_io_8) (int mapped_io_addr);
void (*write_io_8) (int mapped_io_addr, uint8 value);
uint16 (*read_io_16) (int mapped_io_addr);
void (*write_io_16) (int mapped_io_addr, uint16 value);
uint32 (*read_io_32) (int mapped_io_addr);
void (*write_io_32) (int mapped_io_addr, uint32 value);
void * (*ram_address) (const void *physical_address_in_system_memory);
long (*make_isa_dma_table) (
const void *buffer, /* buffer to make a table for */
long buffer_size, /* buffer size */
ulong num_bits, /* dma transfer size that will be used */
isa_dma_entry *table, /* -> caller-supplied scatter/gather table */
long num_entries /* max # entries in table */
);
long (*start_isa_dma) (
long channel, /* dma channel to use */
void *buf, /* buffer to transfer */
long transfer_count, /* # transfers */
uchar mode, /* mode flags */
uchar e_mode /* extended mode flags */
);
long (*start_scattered_isa_dma) (
long channel, /* channel # to use */
const isa_dma_entry *table, /* physical address of scatter/gather table */
uchar mode, /* mode flags */
uchar emode /* extended mode flags */
);
long (*lock_isa_dma_channel) (long channel);
long (*unlock_isa_dma_channel) (long channel);
};
#define B_ISA_MODULE_NAME "bus_managers/isa/v1"
#ifdef __cplusplus
}
#endif
#endif /* _ISA_H */
+222
View File
@@ -0,0 +1,222 @@
/* Kernel only exports for kernel add-ons
*
* Copyright 2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_EXPORT_H
#define _KERNEL_EXPORT_H
#include <SupportDefs.h>
#include <OS.h>
#ifdef __cplusplus
extern "C" {
#endif
/*-------------------------------------------------------------*/
/* interrupts and spinlocks */
/* disable/restore interrupts on the current CPU */
typedef ulong cpu_status;
extern cpu_status disable_interrupts(void);
extern void restore_interrupts(cpu_status status);
/* spinlocks. Note that acquire/release should be called with
* interrupts disabled.
*/
typedef vint32 spinlock;
extern void acquire_spinlock(spinlock *lock);
extern void release_spinlock(spinlock *lock);
/* interrupt handling support for device drivers */
typedef int32 (*interrupt_handler)(void *data);
/* Values returned by interrupt handlers */
#define B_UNHANDLED_INTERRUPT 0 /* pass to next handler */
#define B_HANDLED_INTERRUPT 1 /* don't pass on */
#define B_INVOKE_SCHEDULER 2 /* don't pass on; invoke the scheduler */
/* Flags that can be passed to install_io_interrupt_handler() */
#define B_NO_ENABLE_COUNTER 1
extern status_t install_io_interrupt_handler(long interrupt_number,
interrupt_handler handler, void *data, ulong flags);
extern status_t remove_io_interrupt_handler(long interrupt_number,
interrupt_handler handler, void *data);
/*-------------------------------------------------------------*/
/* timer interrupts services */
/* The BeOS qent structure is probably part of a general double linked list
* interface used all over the kernel; a struct is required to have a qent
* entry struct as first element, so it can be linked to other elements
* easily. The key field is probably just an id, eventually used to order
* the list.
* Since we don't use this kind of interface, but we have to provide it
* to keep compatibility, we can use the qent struct for other purposes...
*
* ToDo: don't do this! Drop source compatibility, but don't overdefine those values!
*/
typedef struct qent {
int64 key; /* We use this as the sched time */
struct qent *next; /* This is used as a pointer to next timer */
struct qent *prev; /* This can be used for callback args */
} qent;
typedef struct timer timer;
typedef int32 (*timer_hook)(timer *);
struct timer {
qent entry;
uint16 flags;
uint16 cpu;
timer_hook hook;
bigtime_t period;
};
#define B_ONE_SHOT_ABSOLUTE_TIMER 1
#define B_ONE_SHOT_RELATIVE_TIMER 2
#define B_PERIODIC_TIMER 3
extern status_t add_timer(timer *t, timer_hook hook, bigtime_t period, int32 flags);
extern bool cancel_timer(timer *t);
/*-------------------------------------------------------------*/
/* kernel threads */
extern thread_id spawn_kernel_thread(thread_func function, const char *threadName,
int32 priority, void *arg);
/*-------------------------------------------------------------*/
/* signal functions */
extern int send_signal_etc(pid_t thread, uint sig, uint32 flags);
/*-------------------------------------------------------------*/
/* virtual memory buffer functions */
#define B_DMA_IO 0x00000001
#define B_READ_DEVICE 0x00000002
typedef struct {
void *address; /* address in physical memory */
ulong size; /* size of block */
} physical_entry;
extern long lock_memory(void *buffer, ulong numBytes, ulong flags);
extern long unlock_memory(void *buffer, ulong numBytes, ulong flags);
extern long get_memory_map(const void *buffer, ulong size,
physical_entry *table, long numEntries);
/* address specifications for mapping physical memory */
#define B_ANY_KERNEL_BLOCK_ADDRESS (B_ANY_KERNEL_ADDRESS + 1)
/* area protection flags for the kernel */
#define B_KERNEL_READ_AREA 16
#define B_KERNEL_WRITE_AREA 32
#define B_USER_CLONEABLE_AREA 256
/* call to map physical memory - typically used for memory-mapped i/o */
extern area_id map_physical_memory(const char *areaName, void *physicalAddress,
size_t size, uint32 flags, uint32 protection, void **mappedAddress);
/* MTR attributes for mapping physical memory (Intel Architecture only) */
// ToDo: what have those to do here?
#define B_MTR_UC 0x10000000
#define B_MTR_WC 0x20000000
#define B_MTR_WT 0x30000000
#define B_MTR_WP 0x40000000
#define B_MTR_WB 0x50000000
#define B_MTR_MASK 0xf0000000
/*-------------------------------------------------------------*/
/* hardware inquiry */
/* platform_type return value is defined in OS.h */
extern platform_type platform();
#if __POWERPC__
extern long motherboard_version(void);
extern long io_card_version(void);
#endif
/*-------------------------------------------------------------*/
/* primitive kernel debugging facilities */
/* Standard debug output is on...
* mac: modem port
* pc: com1
* ...at 19.2 kbaud, no parity, 8 bit, 1 stop bit.
*
* Note: the kernel settings file can override these defaults
*/
#if __GNUC__
extern void dprintf(const char *format, ...) /* just like printf */
__attribute__ ((format (__printf__, 1, 2)));
extern void kprintf(const char *fmt, ...) /* only for debugger cmds */
__attribute__ ((format (__printf__, 1, 2)));
#else
extern void dprintf(const char *format, ...); /* just like printf */
extern void kprintf(const char *fmt, ...); /* only for debugger cmds */
#endif
extern bool set_dprintf_enabled(bool new_state); /* returns old state */
extern void panic(const char *format, ...);
extern void kernel_debugger(const char *message); /* enter kernel debugger */
extern uint32 parse_expression(const char *string); /* utility for debugger cmds */
/* special return codes for kernel debugger */
#define B_KDEBUG_CONT 2
#define B_KDEBUG_QUIT 3
typedef int (*debugger_command_hook)(int argc, char **argv);
extern int add_debugger_command(char *name, debugger_command_hook hook, char *help);
extern int remove_debugger_command(char *name, debugger_command_hook hook);
extern status_t load_driver_symbols(const char *driverName);
/*-------------------------------------------------------------*/
/* misc */
extern void spin(bigtime_t microseconds);
/* does a busy delay loop for at least "microseconds" */
typedef void (*daemon_hook)(void *arg, int iteration);
extern status_t register_kernel_daemon(daemon_hook hook, void *arg, int frequency);
extern status_t unregister_kernel_daemon(daemon_hook hook, void *arg);
extern void call_all_cpus(void (*f)(void *, int), void *cookie);
/* safe methods to access user memory without having to lock it */
extern status_t user_memcpy(void *to, const void *from, size_t size);
extern ssize_t user_strlcpy(char *to, const char *from, size_t size);
extern status_t user_memset(void *start, char c, size_t count);
#ifdef __cplusplus
}
#endif
#endif /* _KERNEL_EXPORT_H */
+604
View File
@@ -0,0 +1,604 @@
/*******************************************************************************
/
/ File: PCI.h
/
/ Description: Interface to the PCI bus.
/ For more information, see "PCI Local Bus Specification, Revision 2.1",
/ PCI Special Interest Group, 1995.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _PCI_H
#define _PCI_H
//#include <BeBuild.h>
//#include <SupportDefs.h>
#include <bus_manager.h>
#ifdef __cplusplus
extern "C" {
#endif
/* -----
pci device info
----- */
typedef struct pci_info {
ushort vendor_id; /* vendor id */
ushort device_id; /* device id */
uchar bus; /* bus number */
uchar device; /* device number on bus */
uchar function; /* function number in device */
uchar revision; /* revision id */
uchar class_api; /* specific register interface type */
uchar class_sub; /* specific device function */
uchar class_base; /* device type (display vs network, etc) */
uchar line_size; /* cache line size in 32 bit words */
uchar latency; /* latency timer */
uchar header_type; /* header type */
uchar bist; /* built-in self-test */
uchar reserved; /* filler, for alignment */
union {
struct {
ulong cardbus_cis; /* CardBus CIS pointer */
ushort subsystem_id; /* subsystem (add-in card) id */
ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */
ulong rom_base; /* rom base address, viewed from host */
ulong rom_base_pci; /* rom base addr, viewed from pci */
ulong rom_size; /* rom size */
ulong base_registers[6]; /* base registers, viewed from host */
ulong base_registers_pci[6]; /* base registers, viewed from pci */
ulong base_register_sizes[6]; /* size of what base regs point to */
uchar base_register_flags[6]; /* flags from base address fields */
uchar interrupt_line; /* interrupt line */
uchar interrupt_pin; /* interrupt pin */
uchar min_grant; /* burst period @ 33 Mhz */
uchar max_latency; /* how often PCI access needed */
} h0;
struct {
ulong base_registers[2]; /* base registers, viewed from host */
ulong base_registers_pci[2]; /* base registers, viewed from pci */
ulong base_register_sizes[2]; /* size of what base regs point to */
uchar base_register_flags[2]; /* flags from base address fields */
uchar primary_bus;
uchar secondary_bus;
uchar subordinate_bus;
uchar secondary_latency;
uchar io_base;
uchar io_limit;
ushort secondary_status;
ushort memory_base;
ushort memory_limit;
ushort prefetchable_memory_base;
ushort prefetchable_memory_limit;
ulong prefetchable_memory_base_upper32;
ulong prefetchable_memory_limit_upper32;
ushort io_base_upper16;
ushort io_limit_upper16;
ulong rom_base; /* rom base address, viewed from host */
ulong rom_base_pci; /* rom base addr, viewed from pci */
uchar interrupt_line; /* interrupt line */
uchar interrupt_pin; /* interrupt pin */
ushort bridge_control;
ushort subsystem_id; /* subsystem (add-in card) id */
ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */
} h1;
struct {
ushort subsystem_id; /* subsystem (add-in card) id */
ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */
} h2;
} u;
} pci_info;
typedef struct pci_module_info pci_module_info;
struct pci_module_info {
bus_manager_info binfo;
uint8 (*read_io_8) (int mapped_io_addr);
void (*write_io_8) (int mapped_io_addr, uint8 value);
uint16 (*read_io_16) (int mapped_io_addr);
void (*write_io_16) (int mapped_io_addr, uint16 value);
uint32 (*read_io_32) (int mapped_io_addr);
void (*write_io_32) (int mapped_io_addr, uint32 value);
long (*get_nth_pci_info) (
long index, /* index into pci device table */
pci_info *info /* caller-supplied buffer for info */
);
uint32 (*read_pci_config) (
uchar bus, /* bus number */
uchar device, /* device # on bus */
uchar function, /* function # in device */
uchar offset, /* offset in configuration space */
uchar size /* # bytes to read (1, 2 or 4) */
);
void (*write_pci_config) (
uchar bus, /* bus number */
uchar device, /* device # on bus */
uchar function, /* function # in device */
uchar offset, /* offset in configuration space */
uchar size, /* # bytes to write (1, 2 or 4) */
uint32 value /* value to write */
);
void * (*ram_address) (const void *physical_address_in_system_memory);
};
#define B_PCI_MODULE_NAME "bus_managers/pci/v1"
/* ---
offsets in PCI configuration space to the elements of the predefined
header common to all header types
--- */
#define PCI_vendor_id 0x00 /* (2 byte) vendor id */
#define PCI_device_id 0x02 /* (2 byte) device id */
#define PCI_command 0x04 /* (2 byte) command */
#define PCI_status 0x06 /* (2 byte) status */
#define PCI_revision 0x08 /* (1 byte) revision id */
#define PCI_class_api 0x09 /* (1 byte) specific register interface type */
#define PCI_class_sub 0x0a /* (1 byte) specific device function */
#define PCI_class_base 0x0b /* (1 byte) device type (display vs network, etc) */
#define PCI_line_size 0x0c /* (1 byte) cache line size in 32 bit words */
#define PCI_latency 0x0d /* (1 byte) latency timer */
#define PCI_header_type 0x0e /* (1 byte) header type */
#define PCI_bist 0x0f /* (1 byte) built-in self-test */
/* ---
offsets in PCI configuration space to the elements of the predefined
header common to header types 0x00 and 0x01
--- */
#define PCI_base_registers 0x10 /* base registers (size varies) */
#define PCI_interrupt_line 0x3c /* (1 byte) interrupt line */
#define PCI_interrupt_pin 0x3d /* (1 byte) interrupt pin */
/* ---
offsets in PCI configuration space to the elements of header type 0x00
--- */
#define PCI_cardbus_cis 0x28 /* (4 bytes) CardBus CIS (Card Information Structure) pointer (see PCMCIA v2.10 Spec) */
#define PCI_subsystem_vendor_id 0x2c /* (2 bytes) subsystem (add-in card) vendor id */
#define PCI_subsystem_id 0x2e /* (2 bytes) subsystem (add-in card) id */
#define PCI_rom_base 0x30 /* (4 bytes) expansion rom base address */
#define PCI_capabilities_ptr 0x34 /* (1 byte) pointer to the start of the capabilities list */
#define PCI_min_grant 0x3e /* (1 byte) burst period @ 33 Mhz */
#define PCI_max_latency 0x3f /* (1 byte) how often PCI access needed */
/* ---
offsets in PCI configuration space to the elements of header type 0x01 (PCI-to-PCI bridge)
--- */
#define PCI_primary_bus 0x18 /* (1 byte) */
#define PCI_secondary_bus 0x19 /* (1 byte) */
#define PCI_subordinate_bus 0x1A /* (1 byte) */
#define PCI_secondary_latency 0x1B /* (1 byte) latency of secondary bus */
#define PCI_io_base 0x1C /* (1 byte) io base address register for 2ndry bus*/
#define PCI_io_limit 0x1D /* (1 byte) */
#define PCI_secondary_status 0x1E /* (2 bytes) */
#define PCI_memory_base 0x20 /* (2 bytes) */
#define PCI_memory_limit 0x22 /* (2 bytes) */
#define PCI_prefetchable_memory_base 0x24 /* (2 bytes) */
#define PCI_prefetchable_memory_limit 0x26 /* (2 bytes) */
#define PCI_prefetchable_memory_base_upper32 0x28
#define PCI_prefetchable_memory_limit_upper32 0x2C
#define PCI_io_base_upper16 0x30 /* (2 bytes) */
#define PCI_io_limit_upper16 0x32 /* (2 bytes) */
#define PCI_sub_vendor_id_1 0x34 /* (2 bytes) */
#define PCI_sub_device_id_1 0x36 /* (2 bytes) */
#define PCI_bridge_rom_base 0x38
#define PCI_bridge_control 0x3E /* (1 byte) */
/* PCI type 2 header offsets */
#define PCI_capabilities_ptr_2 0x14 /* (1 byte) */
#define PCI_secondary_status_2 0x16 /* (2 bytes) */
#define PCI_primary_bus_2 0x18 /* (1 byte) */
#define PCI_secondary_bus_2 0x19 /* (1 byte) */
#define PCI_subordinate_bus_2 0x1A /* (1 byte) */
#define PCI_secondary_latency_2 0x1B /* (1 byte) latency of secondary bus */
#define PCI_memory_base0_2 0x1C /* (4 bytes) */
#define PCI_memory_limit0_2 0x20 /* (4 bytes) */
#define PCI_memory_base1_2 0x24 /* (4 bytes) */
#define PCI_memory_limit1_2 0x28 /* (4 bytes) */
#define PCI_io_base0_2 0x2c /* (4 bytes) */
#define PCI_io_limit0_2 0x30 /* (4 bytes) */
#define PCI_io_base1_2 0x34 /* (4 bytes) */
#define PCI_io_limit1_2 0x38 /* (4 bytes) */
#define PCI_bridge_control_2 0x3E /* (1 byte) */
#define PCI_sub_vendor_id_2 0x40 /* (2 bytes) */
#define PCI_sub_device_id_2 0x42 /* (2 bytes) */
#define PCI_card_interface_2 0x44 /* ?? */
/* ---
values for the class_base field in the common header
--- */
#define PCI_early 0x00 /* built before class codes defined */
#define PCI_mass_storage 0x01 /* mass storage_controller */
#define PCI_network 0x02 /* network controller */
#define PCI_display 0x03 /* display controller */
#define PCI_multimedia 0x04 /* multimedia device */
#define PCI_memory 0x05 /* memory controller */
#define PCI_bridge 0x06 /* bridge controller */
#define PCI_simple_communications 0x07 /* simple communications controller */
#define PCI_base_peripheral 0x08 /* base system peripherals */
#define PCI_input 0x09 /* input devices */
#define PCI_docking_station 0x0a /* docking stations */
#define PCI_processor 0x0b /* processors */
#define PCI_serial_bus 0x0c /* serial_bus_controller */
#define PCI_wireless 0x0d
#define PCI_intelligent_io 0x0e
#define PCI_satellite_communications 0x0f
#define PCI_encryption_decryption 0x10
#define PCI_data_acquisition 0x11
#define PCI_undefined 0xFF /* not in any defined class */
/* ---
values for the class_sub field for class_base = 0x00 (built before
class codes were defined)
--- */
#define PCI_early_not_vga 0x00 /* all except vga */
#define PCI_early_vga 0x01 /* vga devices */
/* ---
values for the class_sub field for class_base = 0x01 (mass storage)
--- */
#define PCI_scsi 0x00 /* SCSI controller */
#define PCI_ide 0x01 /* IDE controller */
#define PCI_floppy 0x02 /* floppy disk controller */
#define PCI_ipi 0x03 /* IPI bus controller */
#define PCI_raid 0x04 /* RAID controller */
#define PCI_mass_storage_other 0x80 /* other mass storage controller */
/* ---
values for the class_sub field for class_base = 0x02 (network)
--- */
#define PCI_ethernet 0x00 /* Ethernet controller */
#define PCI_token_ring 0x01 /* Token Ring controller */
#define PCI_fddi 0x02 /* FDDI controller */
#define PCI_atm 0x03 /* ATM controller */
#define PCI_isdn 0x04 /* ISDN controller */
#define PCI_network_other 0x80 /* other network controller */
/* ---
values for the class_sub field for class_base = 0x03 (display)
--- */
#define PCI_vga 0x00 /* VGA controller */
#define PCI_xga 0x01 /* XGA controller */
#define PCI_3d 0x02 /* £d controller */
#define PCI_display_other 0x80 /* other display controller */
/* ---
values for the class_sub field for class_base = 0x04 (multimedia device)
--- */
#define PCI_video 0x00 /* video */
#define PCI_audio 0x01 /* audio */
#define PCI_telephony 0x02 /* computer telephony device */
#define PCI_multimedia_other 0x80 /* other multimedia device */
/* ---
values for the class_sub field for class_base = 0x05 (memory)
--- */
#define PCI_ram 0x00 /* RAM */
#define PCI_flash 0x01 /* flash */
#define PCI_memory_other 0x80 /* other memory controller */
/* ---
values for the class_sub field for class_base = 0x06 (bridge)
--- */
#define PCI_host 0x00 /* host bridge */
#define PCI_isa 0x01 /* ISA bridge */
#define PCI_eisa 0x02 /* EISA bridge */
#define PCI_microchannel 0x03 /* MicroChannel bridge */
#define PCI_pci 0x04 /* PCI-to-PCI bridge */
#define PCI_pcmcia 0x05 /* PCMCIA bridge */
#define PCI_nubus 0x06 /* NuBus bridge */
#define PCI_cardbus 0x07 /* CardBus bridge */
#define PCI_raceway 0x08 /* RACEway bridge */
#define PCI_bridge_other 0x80 /* other bridge device */
/* ---
values for the class_sub field for class_base = 0x07 (simple
communications controllers)
--- */
#define PCI_serial 0x00 /* serial port controller */
#define PCI_parallel 0x01 /* parallel port */
#define PCI_multiport_serial 0x02 /* multiport serial controller */
#define PCI_modem 0x03 /* modem */
#define PCI_simple_communications_other 0x80 /* other communications device */
/* ---
values of the class_api field for
class_base = 0x07 (simple communications), and
class_sub = 0x00 (serial port controller)
--- */
#define PCI_serial_xt 0x00 /* XT-compatible serial controller */
#define PCI_serial_16450 0x01 /* 16450-compatible serial controller */
#define PCI_serial_16550 0x02 /* 16550-compatible serial controller */
/* ---
values of the class_api field for
class_base = 0x07 (simple communications), and
class_sub = 0x01 (parallel port)
--- */
#define PCI_parallel_simple 0x00 /* simple (output-only) parallel port */
#define PCI_parallel_bidirectional 0x01 /* bidirectional parallel port */
#define PCI_parallel_ecp 0x02 /* ECP 1.x compliant parallel port */
/* ---
values for the class_sub field for class_base = 0x08 (generic
system peripherals)
--- */
#define PCI_pic 0x00 /* periperal interrupt controller */
#define PCI_dma 0x01 /* dma controller */
#define PCI_timer 0x02 /* timers */
#define PCI_rtc 0x03 /* real time clock */
#define PCI_generic_hot_plug 0x04 /* generic PCI hot-plug controller */
#define PCI_system_peripheral_other 0x80 /* other generic system peripheral */
/* ---
values of the class_api field for
class_base = 0x08 (generic system peripherals)
class_sub = 0x00 (peripheral interrupt controller)
--- */
#define PCI_pic_8259 0x00 /* generic 8259 */
#define PCI_pic_isa 0x01 /* ISA pic */
#define PCI_pic_eisa 0x02 /* EISA pic */
/* ---
values of the class_api field for
class_base = 0x08 (generic system peripherals)
class_sub = 0x01 (dma controller)
--- */
#define PCI_dma_8237 0x00 /* generic 8237 */
#define PCI_dma_isa 0x01 /* ISA dma */
#define PCI_dma_eisa 0x02 /* EISA dma */
/* ---
values of the class_api field for
class_base = 0x08 (generic system peripherals)
class_sub = 0x02 (timer)
--- */
#define PCI_timer_8254 0x00 /* generic 8254 */
#define PCI_timer_isa 0x01 /* ISA timer */
#define PCI_timer_eisa 0x02 /* EISA timers (2 timers) */
/* ---
values of the class_api field for
class_base = 0x08 (generic system peripherals)
class_sub = 0x03 (real time clock
--- */
#define PCI_rtc_generic 0x00 /* generic real time clock */
#define PCI_rtc_isa 0x01 /* ISA real time clock */
/* ---
values for the class_sub field for class_base = 0x09 (input devices)
--- */
#define PCI_keyboard 0x00 /* keyboard controller */
#define PCI_pen 0x01 /* pen */
#define PCI_mouse 0x02 /* mouse controller */
#define PCI_scanner 0x03 /* scanner controller */
#define PCI_gameport 0x04 /* gameport controller */
#define PCI_input_other 0x80 /* other input controller */
/* ---
values for the class_sub field for class_base = 0x0a (docking stations)
--- */
#define PCI_docking_generic 0x00 /* generic docking station */
/* ---
values for the class_sub field for class_base = 0x0b (processor)
--- */
#define PCI_386 0x00 /* 386 */
#define PCI_486 0x01 /* 486 */
#define PCI_pentium 0x02 /* Pentium */
#define PCI_alpha 0x10 /* Alpha */
#define PCI_PowerPC 0x20 /* PowerPC */
#define PCI_mips 0x30 /* MIPS */
#define PCI_coprocessor 0x40 /* co-processor */
/* ---
values for the class_sub field for class_base = 0x0c (serial bus
controller)
--- */
#define PCI_firewire 0x00 /* FireWire (IEEE 1394) */
#define PCI_access 0x01 /* ACCESS bus */
#define PCI_ssa 0x02 /* SSA */
#define PCI_usb 0x03 /* Universal Serial Bus */
#define PCI_fibre_channel 0x04 /* Fibre channel */
/* ---
values of the class_api field for
class_base = 0x0c ( serial bus controller )
class_sub = 0x03 ( Universal Serial Bus )
--- */
#define PCI_usb_uhci 0x00 /* Universal Host Controller Interface */
#define PCI_usb_ohci 0x10 /* Open Host Controller Interface */
/* ---
masks for command register bits
--- */
#define PCI_command_io 0x001 /* 1/0 i/o space en/disabled */
#define PCI_command_memory 0x002 /* 1/0 memory space en/disabled */
#define PCI_command_master 0x004 /* 1/0 pci master en/disabled */
#define PCI_command_special 0x008 /* 1/0 pci special cycles en/disabled */
#define PCI_command_mwi 0x010 /* 1/0 memory write & invalidate en/disabled */
#define PCI_command_vga_snoop 0x020 /* 1/0 vga pallette snoop en/disabled */
#define PCI_command_parity 0x040 /* 1/0 parity check en/disabled */
#define PCI_command_address_step 0x080 /* 1/0 address stepping en/disabled */
#define PCI_command_serr 0x100 /* 1/0 SERR# en/disabled */
#define PCI_command_fastback 0x200 /* 1/0 fast back-to-back en/disabled */
/* ---
masks for status register bits
--- */
#define PCI_status_capabilities 0x0010 /* capabilities list */
#define PCI_status_66_MHz_capable 0x0020 /* 66 Mhz capable */
#define PCI_status_udf_supported 0x0040 /* user-definable-features (udf) supported */
#define PCI_status_fastback 0x0080 /* fast back-to-back capable */
#define PCI_status_parity_signalled 0x0100 /* parity error signalled */
#define PCI_status_devsel 0x0600 /* devsel timing (see below) */
#define PCI_status_target_abort_signalled 0x0800 /* signaled a target abort */
#define PCI_status_target_abort_received 0x1000 /* received a target abort */
#define PCI_status_master_abort_received 0x2000 /* received a master abort */
#define PCI_status_serr_signalled 0x4000 /* signalled SERR# */
#define PCI_status_parity_error_detected 0x8000 /* parity error detected */
/* ---
masks for devsel field in status register
--- */
#define PCI_status_devsel_fast 0x0000 /* fast */
#define PCI_status_devsel_medium 0x0200 /* medium */
#define PCI_status_devsel_slow 0x0400 /* slow */
/* ---
masks for header type register
--- */
#define PCI_header_type_mask 0x7F /* header type field */
#define PCI_multifunction 0x80 /* multifunction device flag */
/** types of PCI header */
#define PCI_header_type_generic 0x00
#define PCI_header_type_PCI_to_PCI_bridge 0x01
#define PCI_header_type_cardbus 0x02
/* ---
masks for built in self test (bist) register bits
--- */
#define PCI_bist_code 0x0F /* self-test completion code, 0 = success */
#define PCI_bist_start 0x40 /* 1 = start self-test */
#define PCI_bist_capable 0x80 /* 1 = self-test capable */
/** masks for flags in the various base address registers */
#define PCI_address_space 0x01 /* 0 = memory space, 1 = i/o space */
#define PCI_register_start 0x10
#define PCI_register_end 0x24
#define PCI_register_ppb_end 0x18
#define PCI_register_pcb_end 0x14
/** masks for flags in memory space base address registers */
#define PCI_address_type_32 0x00 /* locate anywhere in 32 bit space */
#define PCI_address_type_32_low 0x02 /* locate below 1 Meg */
#define PCI_address_type_64 0x04 /* locate anywhere in 64 bit space */
#define PCI_address_type 0x06 /* type (see below) */
#define PCI_address_prefetchable 0x08 /* 1 if prefetchable (see PCI spec) */
#define PCI_address_memory_32_mask 0xFFFFFFF0 /* mask to get 32bit memory space base address */
/* ---
masks for flags in i/o space base address registers
--- */
#define PCI_address_io_mask 0xFFFFFFFC /* mask to get i/o space base address */
/* ---
masks for flags in expansion rom base address registers
--- */
#define PCI_rom_enable 0x00000001 /* 1 = expansion rom decode enabled */
#define PCI_rom_address_mask 0xFFFFF800 /* mask to get expansion rom addr */
/** PCI interrupt pin values */
#define PCI_pin_mask 0x07
#define PCI_pin_none 0x00
#define PCI_pin_a 0x01
#define PCI_pin_b 0x02
#define PCI_pin_c 0x03
#define PCI_pin_d 0x04
#define PCI_pin_max 0x04
/** PCI Capability Codes */
#define PCI_cap_id_reserved 0x00
#define PCI_cap_id_pm 0x01 /* Power management */
#define PCI_cap_id_agp 0x02 /* AGP */
#define PCI_cap_id_vpd 0x03 /* Vital product data */
#define PCI_cap_id_slotid 0x04 /* Slot ID */
#define PCI_cap_id_msi 0x05 /* Message signalled interrupt ??? */
#define PCI_cap_id_chswp 0x06 /* Compact PCI HotSwap */
#define PCI_cap_id_pcix 0x07
#define PCI_cap_id_ldt 0x08
#define PCI_cap_id_vendspec 0x09
#define PCI_cap_id_debugport 0x0a
#define PCI_cap_id_cpci_rsrcctl 0x0b
#define PCI_cap_id_hotplug 0x0c
/** Power Management Control Status Register settings */
#define PCI_pm_mask 0x03
#define PCI_pm_ctrl 0x02
#define PCI_pm_d1supp 0x0200
#define PCI_pm_d2supp 0x0400
#define PCI_pm_status 0x04
#define PCI_pm_state_d0 0x00
#define PCI_pm_state_d1 0x01
#define PCI_pm_state_d2 0x02
#define PCI_pm_state_d3 0x03
#ifdef __cplusplus
}
#endif
#endif /* _PCI_H */
+44
View File
@@ -0,0 +1,44 @@
/* File System and Drivers select support
**
** Distributed under the terms of the Haiku License.
*/
#ifndef _DRIVERS_SELECT_H
#define _DRIVERS_SELECT_H
#include <SupportDefs.h>
struct selectsync;
typedef struct selectsync selectsync;
enum select_events {
B_SELECT_READ = 1, // standard select() support
B_SELECT_WRITE,
B_SELECT_ERROR,
B_SELECT_PRI_READ, // additional poll() support
B_SELECT_PRI_WRITE,
B_SELECT_HIGH_PRI_READ,
B_SELECT_HIGH_PRI_WRITE,
B_SELECT_DISCONNECTED
};
#ifdef __cplusplus
extern "C" {
#endif
#ifdef COMPILE_FOR_R5
extern void notify_select_event(struct selectsync *sync, uint32 ref);
#else
extern status_t notify_select_event(struct selectsync *sync, uint32 ref, uint8 event);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _DRIVERS_SELECT_H */
+189
View File
@@ -0,0 +1,189 @@
/*
** USB.h - Version 2 USB Device Driver API
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
*/
#ifndef _USB_H
#define _USB_H
#include <KernelExport.h>
#include <bus_manager.h>
#include <USB_spec.h>
#include <USB_rle.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct usb_module_info usb_module_info;
/* these are opaque handles to internal stack objects */
typedef struct usb_device usb_device;
typedef struct usb_interface usb_interface;
typedef struct usb_pipe usb_pipe;
typedef struct usb_endpoint_info usb_endpoint_info;
typedef struct usb_interface_info usb_interface_info;
typedef struct usb_interface_list usb_interface_list;
typedef struct usb_configuration_info usb_configuration_info;
typedef struct usb_notify_hooks {
status_t (*device_added)(const usb_device *device, void **cookie);
status_t (*device_removed)(void *cookie);
} usb_notify_hooks;
typedef struct usb_support_descriptor {
uint8 dev_class;
uint8 dev_subclass;
uint8 dev_protocol;
uint16 vendor;
uint16 product;
} usb_support_descriptor;
/* ie, I support any hub device:
** usb_support_descriptor hub_devs = { 9, 0, 0, 0, 0 };
*/
struct usb_endpoint_info {
usb_endpoint_descriptor *descr; /* descriptor and handle */
usb_pipe *handle; /* of this endpoint/pipe */
};
struct usb_interface_info {
usb_interface_descriptor *descr; /* descriptor and handle */
usb_interface *handle; /* of this interface */
size_t endpoint_count; /* count and list of endpoints */
usb_endpoint_info *endpoint; /* in this interface */
size_t generic_count; /* unparsed descriptors in this */
usb_descriptor **generic; /* interface */
};
struct usb_interface_list {
size_t alt_count; /* count and list of alternate */
usb_interface_info *alt; /* interfaces available */
usb_interface_info *active; /* currently active alternate */
};
struct usb_configuration_info {
usb_configuration_descriptor *descr; /* descriptor of this config */
size_t interface_count; /* interfaces in this config */
usb_interface_list *interface;
};
typedef void (*usb_callback_func)(void *cookie, uint32 status,
void *data, uint32 actual_len);
struct usb_module_info {
bus_manager_info binfo;
/* inform the bus manager of our intent to support a set of devices */
status_t (*register_driver)(const char *driver_name,
const usb_support_descriptor *descriptors,
size_t count,
const char *optional_republish_driver_name);
/* request notification from the bus manager for add/remove of devices we
support */
status_t (*install_notify)(const char *driver_name,
const usb_notify_hooks *hooks);
status_t (*uninstall_notify)(const char *driver_name);
/* get the device descriptor */
const usb_device_descriptor *(*get_device_descriptor)(const usb_device *dev);
/* get the nth supported configuration */
const usb_configuration_info *(*get_nth_configuration)(const usb_device *dev, uint index);
/* get the active configuration */
const usb_configuration_info *(*get_configuration)(const usb_device *dev);
/* set the active configuration */
status_t (*set_configuration)(const usb_device *dev,
const usb_configuration_info *configuration);
status_t (*set_alt_interface)(const usb_device *dev,
const usb_interface_info *ifc);
/* standard device requests -- convenience functions */
/* obj may be a usb_device*, usb_pipe*, or usb_interface* */
status_t (*set_feature)(const void *object, uint16 selector);
status_t (*clear_feature)(const void *object, uint16 selector);
status_t (*get_status)(const void *object, uint16 *status);
status_t (*get_descriptor)(const usb_device *d,
uint8 type, uint8 index, uint16 lang,
void *data, size_t len, size_t *actual_len);
/* generic device request function */
status_t (*send_request)(const usb_device *d,
uint8 request_type, uint8 request,
uint16 value, uint16 index, uint16 length,
void *data, size_t data_len, size_t *actual_len);
/* async request queueing */
status_t (*queue_interrupt)(const usb_pipe *handle,
void *data, size_t len,
usb_callback_func notify, void *cookie);
status_t (*queue_bulk)(const usb_pipe *handle,
void *data, size_t len,
usb_callback_func notify, void *cookie);
status_t (*queue_isochronous)(const usb_pipe *handle,
void *data, size_t len,
rlea* rle_array, uint16 buffer_duration_ms,
usb_callback_func notify, void *cookie);
status_t (*queue_request)(const usb_device *d,
uint8 request_type, uint8 request,
uint16 value, uint16 index, uint16 length,
void *data, size_t data_len,
usb_callback_func notify, void *cookie);
status_t (*set_pipe_policy)(const usb_pipe *handle, uint8 max_num_queued_packets,
uint16 max_buffer_duration_ms, uint16 sample_size);
/* cancel pending async requests to an endpoint */
status_t (*cancel_queued_transfers)(const usb_pipe *handle);
/* tuning, timeouts, etc */
status_t (*usb_ioctl)(uint32 opcode, void* buf, size_t buf_size);
};
/* status code for usb callback functions */
#define B_USB_STATUS_SUCCESS 0x0000
#define B_USB_STATUS_DEVICE_CRC_ERROR 0x0002
#define B_USB_STATUS_DEVICE_TIMEOUT 0x0004
#define B_USB_STATUS_DEVICE_STALLED 0x0008
#define B_USB_STATUS_IRP_CANCELLED_BY_REQUEST 0x0010
#define B_USB_STATUS_DRIVER_INTERNAL_ERROR 0x0020
#define B_USB_STATUS_ADAPTER_HARDWARE_ERROR 0x0040
#define B_USB_STATUS_ISOCH_IRP_ABORTED 0x0080
/* result codes for usb bus manager functions */
#define B_USBD_SUCCESS 0
#define B_USBD_BAD_HANDLE 1
#define B_USBD_BAD_ARGS 2
#define B_USBD_NO_DATA 3
#define B_USBD_DEVICE_FAILURE 4
#define B_USBD_COMMAND_FAILED 5
#define B_USBD_PIPE_NOT_CONFIGURED 6
#define B_USBD_DEVICE_ERROR 7
#define B_USBD_PIPE_ERROR 8
#define B_USBD_NO_MEMORY 9
#define B_USB_MODULE_NAME "bus_managers/usb/v2"
#ifdef __cplusplus
}
#endif
#endif
+36
View File
@@ -0,0 +1,36 @@
/*
** USB_printer.h
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
*/
#ifndef _USB_PRINTER_H
#define _USB_PRINTER_H
#include <Drivers.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ioctl() opcodes for usb_printer driver */
enum
{
USB_PRINTER_GET_DEVICE_ID = B_DEVICE_OP_CODES_END+1
};
/* Maximum length of the DEVICE_ID. User MUST allocate this size
when calling USB_PRINTER_GET_DEVICE_ID ioctl() */
#define USB_PRINTER_DEVICE_ID_LENGTH 256
#ifdef __cplusplus
}
#endif
#endif
+91
View File
@@ -0,0 +1,91 @@
/*
** USB_rle.h
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
*/
#ifndef _USB_RLE_H
#define _USB_RLE_H
#ifdef __cplusplus
extern "C" {
#endif
struct _usbd_param_hdr;
/*
Run Length encoding records for isochronous IN transfers.
Run Length encoding records are used to identify which samples in
the buffer are good which are bad and which are missing.
Bad bytes are not extracted from the buffer, but are padded to next
nearest sample boundary. The ultimate consumer of the buffer
should also receive the RLE array.
RLE records are constructed based on the following rules:
1. an RLE record contains a sample count and a status
(good, bad, missing or unknown). A buffer has
associated with it an array of rle records. The number of
rle records available is specified in the RLE header. The
number used is also in the RLE header.
2. Within the scope of a buffer, successive packets with the
same completion status are represented with (1) rle record.
For example, after three transactions which have completion
status of success, the byte count in the rle record for this
position in the data stream represents the bytes received in
all three packets.
3. New rle records are initialized each time the status for a
given packet differs from that of the previous packet.
*/
#define RLE_GOOD 1
#define RLE_BAD 2
#define RLE_MISSING 3
#define RLE_UNKNOWN 4
/*
Name: rle
Purpose: used to represent the state of a portion of a data buffer
Fields:
rle_status will contain only the values: RLE_GOOD, RLE_BAD, RLE_MISSING
sample_count the number of usb samples in the buffer associated with this rle
record.
Notes:
If the buffer length field in queue_buffer_single structure changes to an
uint32 from uin16, then the sample_count data type must
track this change.
*/
typedef struct rle {
uint16 rle_status;
uint16 sample_count;
} rle;
/*
Name: rlea
Purpose: used as the primary rle information data structure between the
USB driver stack and a consuming client.
Fields:
length the number of rle records available in this structure.
num_valid filled in by the USB driver. indicates the number of valid
records filled.
rles[] unconstrained array of rle records.
*/
typedef struct rlea {
uint16 length;
uint16 num_valid;
rle rles[1];
} rlea;
#ifdef __cplusplus
}
#endif
#endif
+144
View File
@@ -0,0 +1,144 @@
/*
** USB_spec.h
**
** Copyright 1999, Be Incorporated. All Rights Reserved.
**
** This file contains structures and constants based on the USB Specification 1.1
**
*/
#ifndef _USB_SPEC_H
#define _USB_SPEC_H
#ifdef __cplusplus
extern "C" {
#endif
/* request types (target & direction) for send_request() */
/* cf USB Spec Rev 1.1, table 9-2, p 183 */
#define USB_REQTYPE_DEVICE_IN 0x80
#define USB_REQTYPE_DEVICE_OUT 0x00
#define USB_REQTYPE_INTERFACE_IN 0x81
#define USB_REQTYPE_INTERFACE_OUT 0x01
#define USB_REQTYPE_ENDPOINT_IN 0x82
#define USB_REQTYPE_ENDPOINT_OUT 0x02
#define USB_REQTYPE_OTHER_OUT 0x03
#define USB_REQTYPE_OTHER_IN 0x83
/* request types for send_request() */
/* cf USB Spec Rev 1.1, table 9-2, p 183 */
#define USB_REQTYPE_STANDARD 0x00
#define USB_REQTYPE_CLASS 0x20
#define USB_REQTYPE_VENDOR 0x40
#define USB_REQTYPE_RESERVED 0x60
#define USB_REQTYPE_MASK 0x9F
/* standard request values for send_request() */
/* cf USB Spec Rev 1.1, table 9-4, p 187 */
#define USB_REQUEST_GET_STATUS 0
#define USB_REQUEST_CLEAR_FEATURE 1
#define USB_REQUEST_SET_FEATURE 3
#define USB_REQUEST_SET_ADDRESS 5
#define USB_REQUEST_GET_DESCRIPTOR 6
#define USB_REQUEST_SET_DESCRIPTOR 7
#define USB_REQUEST_GET_CONFIGURATION 8
#define USB_REQUEST_SET_CONFIGURATION 9
#define USB_REQUEST_GET_INTERFACE 10
#define USB_REQUEST_SET_INTERFACE 11
#define USB_REQUEST_SYNCH_FRAME 12
/* used by {set,get}_descriptor() */
/* cf USB Spec Rev 1.1, table 9-5, p 187 */
#define USB_DESCRIPTOR_DEVICE 1
#define USB_DESCRIPTOR_CONFIGURATION 2
#define USB_DESCRIPTOR_STRING 3
#define USB_DESCRIPTOR_INTERFACE 4
#define USB_DESCRIPTOR_ENDPOINT 5
/* used by {set,clear}_feature() */
/* cf USB Spec Rev 1.1, table 9-6, p 188 */
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1
#define USB_FEATURE_ENDPOINT_HALT 0
typedef struct {
/* cf USB Spec Rev 1.1, table 9-7, p 197 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_DEVICE */
uint16 usb_version; /* USB_DESCRIPTOR_DEVICE_LENGTH */
uint8 device_class;
uint8 device_subclass;
uint8 device_protocol;
uint8 max_packet_size_0;
uint16 vendor_id;
uint16 product_id;
uint16 device_version;
uint8 manufacturer;
uint8 product;
uint8 serial_number;
uint8 num_configurations;
} _PACKED usb_device_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-8, p 199 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_CONFIGURATION */
uint16 total_length; /* USB_DESCRIPTOR_CONFIGURATION_LENGTH */
uint8 number_interfaces;
uint8 configuration_value;
uint8 configuration;
uint8 attributes;
uint8 max_power;
} _PACKED usb_configuration_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-9, p 202 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_INTERFACE */
uint8 interface_number; /* USB_DESCRIPTOR_INTERFACE_LENGTH */
uint8 alternate_setting;
uint8 num_endpoints;
uint8 interface_class;
uint8 interface_subclass;
uint8 interface_protocol;
uint8 interface;
} _PACKED usb_interface_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-10, p 203 */
uint8 length;
uint8 descriptor_type; /* USB_DESCRIPTOR_ENDPOINT */
uint8 endpoint_address; /* USB_DESCRIPTOR_ENDPOINT_LENGTH */
uint8 attributes;
uint16 max_packet_size;
uint8 interval;
} _PACKED usb_endpoint_descriptor;
typedef struct {
/* cf USB Spec Rev 1.1, table 9-12, p 205 */
uint8 length; /* USB_DESCRIPTOR_STRING */
uint8 descriptor_type;
uchar string[1];
} _PACKED usb_string_descriptor;
typedef struct {
uint8 length;
uint8 descriptor_type;
uint8 data[1];
} _PACKED usb_generic_descriptor;
typedef union {
usb_generic_descriptor generic;
usb_device_descriptor device;
usb_interface_descriptor interface;
usb_endpoint_descriptor endpoint;
usb_configuration_descriptor configuration;
usb_string_descriptor string;
} usb_descriptor;
#ifdef __cplusplus
}
#endif
#endif
+97
View File
@@ -0,0 +1,97 @@
/*******************************************************************************
/
/ File: atomizer.h
/
/ Description: Kernel atomizer module API
/
/ Copyright 1999, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _ATOMIZER_MODULE_H_
#define _ATOMIZER_MODULE_H_
#include <module.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
An atomizer is a software device that returns a unique token for a
null-terminated UTF8 string.
Each atomizer comprises a separate token space. The same string interned
in two different atomizers will generate two distinct tokens.
Atomizers and the tokens they generate are only guaranteed valid between
matched calls to get_module/put_module.
void * find_or_make_atomizer(const char *string)
Returns a token that identifies the named atomizer, creating a new
atomizer if the named atomizer does not exist. Pass null, a zero
length string, or the value B_SYSTEM_ATOMIZER_NAME for string will
return a pointer to the system atomizer. Returns (void *)(0)
if the atomizer could not be created (for whatever reason). A return
value of (void *)(-1) refers to the system atomizer.
status_t delete_atomizer(void *atomizer)
Delete the atomizer specified. Returns B_OK if successfull, B_ERROR
otherwise. An error return usually means that a race condition was
detected while destroying the atomizer.
void * atomize(void *atomizer, const char *string, int create)
Return the unique token for the specified string, creating a new token
if the string was not previously atomized and create is non-zero. If
atomizer is (void *)(-1), use the system atomizer (saving the step of
looking it up with find_or_make_atomizer(). Returns (const char *)(0)
if there were any errors detected: insufficient memory or a race
condition with someone deleting the atomizer.
const char * string_for_token(void *atomizer, void *atom)
Return a pointer to the string described by atom in the provided atomizer.
Returns (const char *)(0) if either the atomizer or the atom were invalid.
status_t get_next_atomizer_info(void **cookie, atomizer_info *info)
Returns info about the next atomizer in the list of atomizers by modifying
the contents of info. The pointer specified by *cookie should be set to
(void *)(0) to retrieve the first atomizer, and should not be modified
thereafter. Returns B_ERROR when there are no more atomizers.
Adding or deleting atomizers between calls to get_next_atomizer() results
in a safe but undefined behavior.
void * get_next_atom(void *atomizer, uint32 *cookie)
Returns the next atom interned in specified atomizer, *cookie
should be set to (uint32)(0) to get the first atom. Returns
(void *)(0) when there are no more atoms. Adding atoms between
calls to get_next_atom() may cause atoms to be skipped.
Atomizers are SMP-safe. Check return codes for errors!
*/
#define B_ATOMIZER_MODULE_NAME "generic/atomizer/v1"
#define B_SYSTEM_ATOMIZER_NAME "BeOS System Atomizer"
typedef struct {
void *atomizer; /* An opaque token representing the atomizer. */
char name[B_OS_NAME_LENGTH]; /* The first B_OS_NAME_LENGTH bytes of the atomizer name, null terminated. */
uint32 atom_count; /* The number of atoms currently interned in this atomizer. */
} atomizer_info;
typedef struct {
module_info minfo;
const void * (*find_or_make_atomizer)(const char *string);
status_t (*delete_atomizer)(const void *atomizer);
const void * (*atomize)(const void *atomizer, const char *string, int create);
const char * (*string_for_token)(const void * atomizer, const void *atom);
status_t (*get_next_atomizer_info)(void **cookie, atomizer_info *info);
const void * (*get_next_atom)(const void *atomizer, uint32 *cookie);
} atomizer_module_info;
#ifdef __cplusplus
}
#endif
#endif
+100
View File
@@ -0,0 +1,100 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __BLOCK_IO_H__
#define __BLOCK_IO_H__
/*
Part of Open block device manager
Block devices can be easily written by providing the interface
specified hereinafter. The block device manager takes care of
DMA and other restrictions imposed by underlying controller or
protocol and transparently handles transmission of partial blocks
by using a buffer (performance will suffer, though).
*/
#include <KernelExport.h>
#include <device_manager.h>
// cookies issued by block_io
typedef struct block_io_device_info *block_io_device;
typedef struct block_io_handle_info *block_io_handle;
// cookies issued by device driver
typedef struct block_device_device_cookie *block_device_device_cookie;
typedef struct block_device_handle_cookie *block_device_handle_cookie;
// two reason why to use array of size 1:
// 1. zero-sized arrays aren't standard C
// 2. it's handy if you need a temporary global variable with num=1
typedef struct phys_vecs {
size_t num;
size_t total_len;
physical_entry vec[1];
} phys_vecs;
#define PHYS_VECS(name, size) \
uint8 name[sizeof(phys_vecs) + (size - 1)*sizeof(phys_vec)]; \
phys_vecs *name = (phys_vecs *)name
// Block Device Node
// attributes:
// if true, this device may be a BIOS drive (uint8, optional, default: false)
#define B_BLOCK_DEVICE_IS_BIOS_DRIVE "block_device/is_bios_drive"
// address bits that must be 0 - must be 2^i-1 for some i (uint32, optional, default: 0)
#define B_BLOCK_DEVICE_DMA_ALIGNMENT "block_device/dma_alignment"
// maximum number of blocks per transfer (uint32, optional, default: unlimited)
#define B_BLOCK_DEVICE_MAX_BLOCKS_ITEM "block_device/max_blocks"
// mask of bits that can change in one sg block (uint32, optional, default: ~0)
#define B_BLOCK_DEVICE_DMA_BOUNDARY "block_device/dma_boundary"
// maximum size of one block in scatter/gather list (uint32, optional, default: ~0)
#define B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE "block_device/max_sg_block_size"
// maximum number of scatter/gather blocks (uint32, optional, default: unlimited)
#define B_BLOCK_DEVICE_MAX_SG_BLOCKS "block_device/max_sg_blocks"
// interface to be provided by device driver
typedef struct block_device_interface {
driver_module_info info;
// iovecs are physical address here
// pos and num_blocks are in blocks; bytes_transferred in bytes
// vecs are guaranteed to describe enough data for given block count
status_t (*open)(block_device_device_cookie device, block_device_handle_cookie *handle);
status_t (*close)(block_device_handle_cookie handle);
status_t (*free)(block_device_handle_cookie handle);
status_t (*read)(block_device_handle_cookie handle, const phys_vecs *vecs, off_t pos,
size_t num_blocks, uint32 block_size, size_t *bytes_transferred);
status_t (*write)(block_device_handle_cookie handle, const phys_vecs *vecs, off_t pos,
size_t num_blocks, uint32 block_size, size_t *bytes_transferred);
status_t (*ioctl)(block_device_handle_cookie handle, int op, void *buf, size_t len);
} block_device_interface;
#define B_BLOCK_IO_MODULE_NAME "generic/block_io/v1"
// Interface for Drivers
// blkman interface used for callbacks done by driver
typedef struct block_io_for_driver_interface {
module_info info;
// block_size - block size in bytes
// ld_block_size - log2( block_size) (set to zero if block_size is not power of two)
// capacity - capacity in blocks
void (*set_media_params)(block_io_device device, uint32 block_size, uint32 ld_block_size,
uint64 capacity);
} block_io_for_driver_interface;
#define B_BLOCK_IO_FOR_DRIVER_MODULE_NAME "generic/block_io/driver/v1"
#endif /* __BLOCK_IO_H__ */
+363
View File
@@ -0,0 +1,363 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
Part of Open IDE bus manager
IDE bus manager interface
*/
#ifndef __IDE_H__
#define __IDE_H__
#include <bus_manager.h>
#include <iovec.h>
#include <lendian_bitfield.h>
#include <device_manager.h>
#include <KernelExport.h>
// IDE task file.
// contains the command block interpreted under different conditions with
// first byte being first command register, second byte second command register
// etc.; for lba48, registers must be written twice, therefore there
// are twice as many bytes as registers - the first eight bytes are those
// that must be written first, the second eight bytes are those that
// must be written second.
typedef union {
struct {
uint8 features;
uint8 sector_count;
uint8 sector_number;
uint8 cylinder_0_7;
uint8 cylinder_8_15;
LBITFIELD8_3(
head : 4,
device : 1,
mode : 3
);
uint8 command;
} chs;
struct {
uint8 features;
uint8 sector_count;
uint8 lba_0_7;
uint8 lba_8_15;
uint8 lba_16_23;
LBITFIELD8_3(
lba_24_27 : 4,
device : 1,
mode : 3
);
uint8 command;
} lba;
struct {
LBITFIELD8_3(
dma : 1,
ovl : 1,
_0_res2 : 6
);
LBITFIELD8_2(
_1_res0 : 3,
tag : 5
);
uint8 _2_res;
uint8 byte_count_0_7;
uint8 byte_count_8_15;
LBITFIELD8_6(
lun : 3,
_5_res3 : 1,
device : 1,
_5_one5 : 1,
_5_res6 : 1,
_5_one7 : 1
);
uint8 command;
} packet;
struct {
LBITFIELD8_5(
ili : 1,
eom : 1,
abrt : 1,
_0_res3 : 1,
sense_key : 4
);
LBITFIELD8_4(
cmd_or_data : 1, // 1 - cmd, 0 - data
input_or_output : 1, // 0 - input (to device), 1 - output
release : 1,
tag : 5
);
uint8 _2_res;
uint8 byte_count_0_7;
uint8 byte_count_8_15;
LBITFIELD8_5(
_4_res0 : 4,
device : 1,
_4_obs5 : 1,
_4_res6 : 1,
_4_obs7 : 1
);
LBITFIELD8_7(
chk : 1,
_7_res1 : 2,
drq : 1,
serv : 1,
dmrd : 1,
drdy : 1,
bsy : 1
);
} packet_res;
struct {
uint8 sector_count;
LBITFIELD8_4( // only <tag> is defined for write
cmd_or_data : 1, // 1 - cmd, 0 - data
input_or_output : 1, // 0 - input (to device), 1 - output
release : 1,
tag : 5
);
uint8 lba_0_7;
uint8 lba_8_15;
uint8 lba_16_23;
LBITFIELD8_3(
lba_24_27 : 4,
device : 1,
mode : 3
);
uint8 command;
} queued;
struct {
// low order bytes
uint8 features;
uint8 sector_count_0_7;
uint8 lba_0_7;
uint8 lba_8_15;
uint8 lba_16_23;
LBITFIELD8_3(
_5low_res0 : 4,
device : 1,
mode : 3
);
uint8 command;
// high order bytes
uint8 _0high_res;
uint8 sector_count_8_15;
uint8 lba_24_31;
uint8 lba_32_39;
uint8 lba_40_47;
} lba48;
struct {
// low order bytes
uint8 sector_count_0_7;
LBITFIELD8_4(
cmd_or_data : 1, // 1 - cmd, 0 - data
input_or_output : 1, // 0 - input (to device), 1 - output
release : 1,
tag : 5
);
uint8 lba_0_7;
uint8 lba_8_15;
uint8 lba_16_23;
LBITFIELD8_3(
_5low_res0 : 4,
device : 1,
mode : 3
);
uint8 command;
// high order bytes
uint8 sector_count_8_15;
uint8 _1high_res;
uint8 lba_24_31;
uint8 lba_32_39;
uint8 lba_40_47;
} queued48;
struct {
uint8 _0_res[3];
uint8 ver; // RMSN version
LBITFIELD8_3(
pena : 1, // previously enabled
lock : 1, // capable of locking
pej : 1 // can physically eject
);
} set_MSN_res;
struct {
uint8 r[7+5];
} raw;
struct {
uint8 features;
uint8 sector_count;
uint8 sector_number;
uint8 cylinder_low;
uint8 cylinder_high;
uint8 device_head;
uint8 command;
} write;
struct {
uint8 error;
uint8 sector_count;
uint8 sector_number;
uint8 cylinder_low;
uint8 cylinder_high;
uint8 device_head;
uint8 status;
} read;
} ide_task_file;
// content of "mode" field
enum {
ide_mode_chs = 5,
ide_mode_lba = 7
};
// mask for ide_task_file fields to be written
typedef enum {
ide_mask_features = 0x01,
ide_mask_sector_count = 0x02,
// CHS
ide_mask_sector_number = 0x04,
ide_mask_cylinder_low = 0x08,
ide_mask_cylinder_high = 0x10,
// LBA
ide_mask_LBA_low = 0x04,
ide_mask_LBA_mid = 0x08,
ide_mask_LBA_high = 0x10,
// packet
ide_mask_byte_count = 0x18,
// packet and dma queued result
ide_mask_error = 0x01,
ide_mask_ireason = 0x02,
ide_mask_device_head = 0x20,
ide_mask_command = 0x40,
ide_mask_status = 0x40,
// for 48 bits, the following flags tell which registers to load twice
ide_mask_features_48 = 0x80 | ide_mask_features,
ide_mask_sector_count_48 = 0x80 | ide_mask_sector_count,
ide_mask_LBA_low_48 = 0x100 | ide_mask_LBA_low,
ide_mask_LBA_mid_48 = 0x200 | ide_mask_LBA_mid,
ide_mask_LBA_high_48 = 0x400 | ide_mask_LBA_high,
ide_mask_HOB = 0x780
//ide_mask_all = 0x7f
} ide_reg_mask;
// status register
enum {
ide_status_err = 0x01, // error
ide_status_index = 0x02, // obsolete
ide_status_corr = 0x04, // obsolete
ide_status_drq = 0x08, // data request
ide_status_dsc = 0x10, // reserved
ide_status_service = 0x10, // ready to service device
ide_status_dwf = 0x20, // reserved
ide_status_dma = 0x20, // reserved
ide_status_dmrd = 0x20, // packet: DMA ready
ide_status_df = 0x20, // packet: disk failure
ide_status_drdy = 0x40, // device ready
ide_status_bsy = 0x80 // busy
} ide_status_mask;
// device control register
enum {
// bit 0 must be zero
ide_devctrl_nien = 0x02, // disable INTRQ
ide_devctrl_srst = 0x04, // software device reset
ide_devctrl_bit3 = 0x08, // don't know, but must be set
// bits inbetween are reserved
ide_devctrl_hob = 0x80 // read high order byte (for 48-bit lba)
} ide_devcntrl_mask;
// error register - most bits are command specific
enum {
// always used
ide_error_abrt = 0x04, // command aborted
// used for Ultra DMA modes
ide_error_icrc = 0x80, // interface CRC error
// used by reading data transfers
ide_error_unc = 0x40, // uncorrectable data error
// used by writing data transfers
ide_error_wp = 0x40, // media write protect
// used by all data transfer commands
ide_error_mc = 0x20, // medium changed
ide_error_idnf = 0x10, // CHS translation not init./ invalid CHS address
ide_error_mcr = 0x08, // media change requested
ide_error_nm = 0x02, // no media (for removable media devices)
} ide_error_mask;
typedef struct ide_channel_info *ide_channel_cookie;
// Controller Driver Node
// attributes:
// node type
#define IDE_BUS_TYPE_NAME "bus/ide/v1"
// maximum number of devices connected to controller (uint8, optional, default:2)
#define IDE_CONTROLLER_MAX_DEVICES_ITEM "ide/max_devices"
// set to not-0 if DMA is supported (uint8, optional, default:0)
// (if so, publish necessary blkdev restriction too)
#define IDE_CONTROLLER_CAN_DMA_ITEM "ide/can_DMA"
// set to not-0 if CQ is supported (uint8, optional, default:1)
#define IDE_CONTROLLER_CAN_CQ_ITEM "ide/can_CQ"
// name of controller (string, required)
#define IDE_CONTROLLER_CONTROLLER_NAME_ITEM "ide/controller_name"
// interface of controller driver
typedef struct {
driver_module_info info;
status_t (*write_command_block_regs)
(ide_channel_cookie channel, ide_task_file *tf, ide_reg_mask mask);
status_t (*read_command_block_regs)
(ide_channel_cookie channel, ide_task_file *tf, ide_reg_mask mask);
uint8 (*get_altstatus) (ide_channel_cookie channel);
status_t (*write_device_control) (ide_channel_cookie channel, uint8 val);
status_t (*write_pio) (ide_channel_cookie channel, uint16 *data, int count, bool force_16bit );
status_t (*read_pio) (ide_channel_cookie channel, uint16 *data, int count, bool force_16bit );
status_t (*prepare_dma)(ide_channel_cookie channel,
const physical_entry *sg_list, size_t sg_list_count,
bool write);
status_t (*start_dma)(ide_channel_cookie channel);
status_t (*finish_dma)(ide_channel_cookie channel);
} ide_controller_interface;
// channel cookie, issued by ide bus manager
typedef struct ide_bus_info *ide_channel;
// Interface for Controller Driver
// interface of bus manager as seen from controller driver
// use this interface as the fixed consumer of your controller driver
typedef struct {
driver_module_info info;
// status - status read from controller (_not_ alt_status, as reading
// normal status acknowledges IRQ request of device)
status_t (*irq_handler)( ide_channel channel, uint8 status );
} ide_for_controller_interface;
#define IDE_FOR_CONTROLLER_MODULE_NAME "bus_managers/ide/controller/v1"
#endif /* __IDE_H__ */
+67
View File
@@ -0,0 +1,67 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
ISA bus manager
This is an improper name - this bus manager uses the PnP manager to
load device drivers, but calling it ISA PnP manager would be wrong as
ISA PnP information isn't used at all.
All ISA drivers must be Universal driver (see pnp_manager.h), as they
are all direct children of the ISA bus node. Having an ISA PnP bus manager
(which we don't), one node would be created per ISA device and thus you
could write Specific drivers, but under normal ISA we don't even know
how many devices are there, therefore the Universal driver trick.
Apart from the loading, the main change is the resource manager. In
a driver, you must allocate the resources before registering the node and
deallocate it when your node is removed and if the driver isn't loaded at
this time. If it is, you must delay deallocation until the driver gets
unloaded to make sure no new driver touches the same resources like you
meanwhile.
*/
#ifndef _ISA2_H
#define _ISA2_H
#include <device_manager.h>
#include <ISA.h>
// maximum size of one dma transfer
// (in bytes for 8 bit transfer, in words for 16 bit transfer)
#define B_MAX_ISA_DMA_COUNT 0x10000
typedef struct isa2_module_info {
bus_module_info info;
uint8 (*read_io_8)( int mapped_io_addr );
void (*write_io_8)( int mapped_io_addr, uint8 value );
uint16 (*read_io_16)( int mapped_io_addr );
void (*write_io_16)( int mapped_io_addr, uint16 value );
uint32 (*read_io_32)( int mapped_io_addr );
void (*write_io_32)( int mapped_io_addr, uint32 value );
// don't know what it's for, remains for compatibility
void *(*ram_address)( const void *physical_address_in_system_memory );
// start dma transfer (scattered DMA is not supported as it's EISA specific)
status_t (*start_isa_dma)(
long channel, // dma channel to use
void *buf, // buffer to transfer
long transfer_count, // # transfers
uchar mode, // mode flags
uchar e_mode // extended mode flags
);
} isa2_module_info;
// type of isa device
#define ISA_DEVICE_TYPE_NAME "isa/device/v1"
// directory of ISA drivers
// (there is only one device node, so put all drivers under "universal")
#define ISA_DRIVERS_DIR "isa"
#endif
+158
View File
@@ -0,0 +1,158 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
PCI bus manager
*/
#ifndef _PCI2_H
#define _PCI2_H
#include <device_manager.h>
#include <PCI.h>
// currently, this structure is disabled to avoid collision with R5 header
#if 0
typedef struct pci_info {
ushort vendor_id; /* vendor id */
ushort device_id; /* device id */
uchar bus; /* bus number */
uchar device; /* device number on bus */
uchar function; /* function number in device */
uchar revision; /* revision id */
uchar class_api; /* specific register interface type */
uchar class_sub; /* specific device function */
uchar class_base; /* device type (display vs network, etc) */
uchar line_size; /* cache line size in 32 bit words */
uchar latency; /* latency timer */
uchar header_type; /* header type */
uchar bist; /* built-in self-test */
uchar reserved; /* filler, for alignment */
union {
struct {
ulong cardbus_cis; /* CardBus CIS pointer */
ushort subsystem_id; /* subsystem (add-in card) id */
ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */
ulong rom_base; /* rom base address, viewed from host */
ulong rom_base_pci; /* rom base addr, viewed from pci */
ulong rom_size; /* rom size */
ulong base_registers[6]; /* base registers, viewed from host */
ulong base_registers_pci[6]; /* base registers, viewed from pci */
ulong base_register_sizes[6]; /* size of what base regs point to */
uchar base_register_flags[6]; /* flags from base address fields */
uchar interrupt_line; /* interrupt line */
uchar interrupt_pin; /* interrupt pin */
uchar min_grant; /* burst period @ 33 Mhz */
uchar max_latency; /* how often PCI access needed */
} h0;
struct {
ulong base_registers[2]; /* base registers, viewed from host */
ulong base_registers_pci[2]; /* base registers, viewed from pci */
ulong base_register_sizes[2]; /* size of what base regs point to */
uchar base_register_flags[2]; /* flags from base address fields */
uchar primary_bus;
uchar secondary_bus;
uchar subordinate_bus;
uchar secondary_latency;
uchar io_base;
uchar io_limit;
ushort secondary_status;
ushort memory_base;
ushort memory_limit;
ushort prefetchable_memory_base;
ushort prefetchable_memory_limit;
ulong prefetchable_memory_base_upper32;
ulong prefetchable_memory_limit_upper32;
ushort io_base_upper16;
ushort io_limit_upper16;
ulong rom_base; /* rom base address, viewed from host */
ulong rom_base_pci; /* rom base addr, viewed from pci */
uchar interrupt_line; /* interrupt line */
uchar interrupt_pin; /* interrupt pin */
ushort bridge_control;
} h1;
} u;
} pci_info;
#endif
typedef struct pci_device_info *pci_device;
// Interface to one PCI device.
// Actually, this is a _function_ of a device only, but
// pci_function_module_info would be a bit non-intuitive
typedef struct pci_device_module_info {
driver_module_info info;
uint8 (*read_io_8)(pci_device device, int mapped_io_addr);
void (*write_io_8)(pci_device device, int mapped_io_addr, uint8 value);
uint16 (*read_io_16)(pci_device device, int mapped_io_addr);
void (*write_io_16)(pci_device device, int mapped_io_addr, uint16 value);
uint32 (*read_io_32)(pci_device device, int mapped_io_addr);
void (*write_io_32)(pci_device device, int mapped_io_addr, uint32 value);
uint32 (*read_pci_config)(pci_device device,
uchar offset, /* offset in configuration space */
uchar size); /* # bytes to read (1, 2 or 4) */
void (*write_pci_config)(pci_device device,
uchar offset, /* offset in configuration space */
uchar size, /* # bytes to write (1, 2 or 4) */
uint32 value); /* value to write */
void *(*ram_address)(pci_device device, const void *physical_address_in_system_memory);
/* status_t (*allocate_iomem)( void *base, size_t len, const char *name );
status_t (*release_iomem)( void *base, size_t len );
status_t (*allocate_ioports)( uint16 ioport_base, size_t len, const char *name );
status_t (*release_ioports)( uint16 ioport_base, size_t len );*/
} pci_device_module_info;
// directory of PCI drivers
#define PCI_DRIVERS_DIR "pci"
// attributes of PCI device nodes
// bus idx (uint8)
#define PCI_DEVICE_BUS_ITEM "pci/bus"
// device idx (uint8)
#define PCI_DEVICE_DEVICE_ITEM "pci/device"
// function idx (uint8)
#define PCI_DEVICE_FUNCTION_ITEM "pci/function"
// vendor id (uint16)
#define PCI_DEVICE_VENDOR_ID_ITEM "pci/vendor_id"
// device id (uint16)
#define PCI_DEVICE_DEVICE_ID_ITEM "pci/device_id"
// subsystem id (uint16)
#define PCI_DEVICE_SUBSYSTEM_ID_ITEM "pci/subsystem_id"
// subvendor id (uint16)
#define PCI_DEVICE_SUBVENDOR_ID_ITEM "pci/subvendor_id"
// device base class (uint16)
#define PCI_DEVICE_BASE_CLASS_ID_ITEM "pci/class/base_id"
// device subclass (uint16)
#define PCI_DEVICE_SUB_CLASS_ID_ITEM "pci/class/sub_id"
// device api (uint16)
#define PCI_DEVICE_API_ID_ITEM "pci/class/api_id"
// dynamic consumer patterns for PCI devices
#define PCI_DEVICE_DYNAMIC_CONSUMER_0 \
PCI_DRIVERS_DIR "/" \
"vendor %" PCI_DEVICE_VENDOR_ID_ITEM "%|" \
", device %" PCI_DEVICE_DEVICE_ID_ITEM "%|" \
", subsystem %" PCI_DEVICE_SUBSYSTEM_ID_ITEM "%|" \
", subvendor %" PCI_DEVICE_SUBVENDOR_ID_ITEM "%"
#define PCI_DEVICE_DYNAMIC_CONSUMER_1 \
PCI_DRIVERS_DIR "/" \
"base_class %" PCI_DEVICE_BASE_CLASS_ID_ITEM "%|" \
", sub_class %" PCI_DEVICE_SUB_CLASS_ID_ITEM "%|" \
", api %" PCI_DEVICE_API_ID_ITEM "%"
#endif
+456
View File
@@ -0,0 +1,456 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __SCSI_BUSMANAGER_H__
#define __SCSI_BUSMANAGER_H__
/*
Part of Open SCSI bus manager
SCSI bus manager interface
The bus manager interface is _based_ on CAM, but I've modified it because :-
- HBA engine, target mode and queue freezing (and probably other features)
aren't supported (at least the first two aren't supported by linux too ;)
- Asynchronous events aren't supported (no OS/driver I know uses them)
- P/T/L was defined by number not by handle, requiring many redundant tests
and thus making adding/removing of devices/busses very hard, especially if
PnP is to be supported
- single entry system as proposed by CAM involves extra tests and overhead
because of generalized data structure
For peripheral driver writers:
Something about requests involving data transfer: you can either specify
the virtual address in <data> of CCB (in which case it must be continuous),
or store a pointer to a S/G list that contains physical addresses in
<sg_list>/<sg_cnt>. If <sg_list> is non-Null, <data> is ignored.
The S/G list must be in kernel space because the request can be executed
in a different thread context. This is also the reason why the S/G list has
to contain physical addresses. For obvious reason, the data buffer specified
by <sg_list> must be locked, but <data> doesn't need to be.
You can either execute the request synchronously ("sync_io") or
asynchronously ("async_io"; you have to acquire <completion_sem> to find
out when the request is finished). In the first case you can use either
<data> or <sg_list>, in the latter <sg_list> only.
The SCSI bus manager takes care that the controller can access the data
via DMA by copying it into a buffer if necessary. For the paging path,
this can lead to problems (if the system writes a page to disk and the SCSI
bus manager has to allocate a buffer during execution you are in trouble),
therefore the blk_man takes care that is not necessary for reads/writes.
To safe some microseconds, you should set the SCSI_DMA_SAFE flag for these
requests, so the SCSI bus manager ommittes the test.
Effectively, using synchronous execution and specifying the address via
<data> is a safe bet.
For SIM writers:
Requests sent by peripheral drivers are forwarded to the <scsi_io> entry
of the SIM. You should return as soon as some waiting is required.
Usually, the controller raises an IRQ when a request can be continued
or is finished. As interrupt handlers must be as fast as possible, you
can schedule a DPC in the handler (<schedule_dpc>) which executed by a
high priority service thread that is spawned by the SCSI bus manager
for each bus. This service thread also takes care to submit waiting
requests.
You can specify a maximum number of concurrent requests per bus via
path_inquiry (<hba_queue_size>) for the bus. The device limit is
determined via INQUIRY. If you need a lower/dynamic limit, you can refuse
a request by <requeue>. If <bus_overflow> is true, no further requests
to the bus will be sent, if <bus_overflow> is false, no further requests
to the device will be sent. To terminate the overflow condition, call
<cont_send_device>/<cont_send_bus>. It also terminated when a request
for the bus/device is finished via <finished> or <resubmit>.
Because of the asynchronous nature, requests may still arrive after the
overflow condition being signalled, so you should add a safety test to
<scsi_io>.
If a problem occurs during execution, you can ask for a restart via
<resubmit>. The request in question will be submitted as soon as possible.
If you want to be not disturbed, you can block further requests via
<block_bus>/<block_device>. As said above, you must have a safety test
at <scsi_io> though.
If the SIM uses a non-SCSI protocol, it can ask the SCSI bus manager
to emulate unsupported SCSI commands by translating them other (supported)
commands. The bus manager calls <get_restriction> during detection for
each device, setting <is_atapi> on return makes the bus manager translate
READ6/WRITE6 commands to READ10/WRITE10 commands, MODE REQUEST6/SENSE6
to MODE REQUEST10/SENSE10 and fix the version fields of INQUIRY results,
so ATAPI devices can be used like standard SCSI devices. Further, the
SCSI bus manager can emulate auto-sense by executing a REQUEST SENSE
if <subsys_status> is SCSI_REQ_CMP_ERR and <device_status> is
SCSI_DEVICE_CHECK_CONDITION when a request is finished. This emulation
may be enhanced/generalized in the future.
*/
#include <KernelExport.h>
#include <device_manager.h>
#define SCSI_MAX_CDB_SIZE 16 // max size of cdb
#define SCSI_MAX_SENSE_SIZE 64 // max size of sense data
#define SCSI_SIM_PRIV 1536 // SIM private data; this may be a bit much but
// we currently need that for the compatibility layer
// bus/device handle
typedef struct scsi_bus_info *scsi_bus;
typedef struct scsi_device_info *scsi_device;
// structure of one scsi i/o CCB (command control block)
typedef struct scsi_ccb
{
struct scsi_ccb *next, *prev; // internal
uchar subsys_status; // Returned subsystem status
uchar device_status; // Returned scsi device status
uchar path_id; // Path ID for the request
uchar target_id; // Target device ID
uchar target_lun; // Target LUN number
uint32 flags; // Flags for operation of the subsystem
// released once after asynchronous execution of request;
// initialised by alloc_ccb, can be replaced for action but
// must be restored before returning via free_ccb
sem_id completion_sem;
uint8 cdb[SCSI_MAX_CDB_SIZE]; // command data block
uchar cdb_len; // length of command in bytes
int64 sort; // value of command to sort on (<0 means n/a)
bigtime_t timeout; // timeout - 0 = use default
uchar *data; // pointer to data
const physical_entry *sg_list; // SG list
uint16 sg_cnt; // number of SG entries
uint32 data_len; // length of data
int32 data_resid; // data transfer residual length: 2's comp
uchar sense[SCSI_MAX_SENSE_SIZE]; // autosense data
uchar sense_resid; // autosense resid length: 2's comp
// private
bool ordered : 1; // request cannot overtake/be overtaken by others
bool buffered : 1; // data is buffered to make it DMA safe
bool emulated : 1; // command is executed as part of emulation
scsi_bus bus; // associated bus
scsi_device device; // associated device
struct dma_buffer *dma_buffer; // used dma buffer, or NULL
uchar state; // bus manager state
// original data before command emulation was applied
uint8 orig_cdb[SCSI_MAX_CDB_SIZE];
uchar orig_cdb_len;
const physical_entry *orig_sg_list;
uint16 orig_sg_cnt;
uint32 orig_data_len;
// private SIM data
uchar sim_state; // set to zero when request is submitted first time
uchar sim_priv[SCSI_SIM_PRIV]; /* SIM private data area */
} scsi_ccb;
// Defines for the subsystem status field
#define SCSI_REQ_INPROG 0x00 /* request is in progress */
#define SCSI_REQ_CMP 0x01 /* request completed w/out error */
#define SCSI_REQ_ABORTED 0x02 /* request aborted by the host */
#define SCSI_UA_ABORT 0x03 /* Unable to Abort request */
#define SCSI_REQ_CMP_ERR 0x04 /* request completed with an err */
#define SCSI_BUSY 0x05 /* subsystem is busy */
#define SCSI_REQ_INVALID 0x06 /* request is invalid */
#define SCSI_PATH_INVALID 0x07 /* Path ID supplied is invalid */
#define SCSI_DEV_NOT_THERE 0x08 /* SCSI device not installed/there */
#define SCSI_UA_TERMIO 0x09 /* Unable to Terminate I/O req */
#define SCSI_SEL_TIMEOUT 0x0A /* Target selection timeout */
#define SCSI_CMD_TIMEOUT 0x0B /* Command timeout */
#define SCSI_MSG_REJECT_REC 0x0D /* Message reject received */
#define SCSI_SCSI_BUS_RESET 0x0E /* SCSI bus reset sent/received */
#define SCSI_UNCOR_PARITY 0x0F /* Uncorrectable parity err occurred */
#define SCSI_AUTOSENSE_FAIL 0x10 /* Autosense: Request sense cmd fail */
#define SCSI_NO_HBA 0x11 /* No HBA detected Error */
#define SCSI_DATA_RUN_ERR 0x12 /* Data overrun/underrun error */
#define SCSI_UNEXP_BUSFREE 0x13 /* Unexpected BUS free */
#define SCSI_SEQUENCE_FAIL 0x14 /* Target bus phase sequence failure */
#define SCSI_PROVIDE_FAIL 0x16 /* Unable to provide requ. capability */
#define SCSI_BDR_SENT 0x17 /* A SCSI BDR msg was sent to target */
#define SCSI_REQ_TERMIO 0x18 /* request terminated by the host */
#define SCSI_HBA_ERR 0x19 /* Unrecoverable host bus adaptor err*/
#define SCSI_BUS_RESET_DENIED 0x1A /* SCSI bus reset denied */
#define SCSI_IDE 0x33 /* Initiator Detected Error Received */
#define SCSI_RESRC_UNAVAIL 0x34 /* Resource unavailable */
#define SCSI_UNACKED_EVENT 0x35 /* Unacknowledged event by host */
#define SCSI_LUN_INVALID 0x38 /* LUN supplied is invalid */
#define SCSI_TID_INVALID 0x39 /* Target ID supplied is invalid */
#define SCSI_FUNC_NOTAVAIL 0x3A /* The requ. func is not available */
#define SCSI_NO_NEXUS 0x3B /* Nexus is not established */
#define SCSI_IID_INVALID 0x3C /* The initiator ID is invalid */
#define SCSI_CDB_RECVD 0x3D /* The SCSI CDB has been received */
#define SCSI_LUN_ALLREADY_ENAB 0x3E /* LUN already enabled */
#define SCSI_SCSI_BUSY 0x3F /* SCSI bus busy */
#define SCSI_AUTOSNS_VALID 0x80 /* Autosense data valid for target */
#define SCSI_SUBSYS_STATUS_MASK 0x3F /* Mask bits for just the status # */
// Defines for the flags field
#define SCSI_DIR_RESV 0x00000000 /* Data direction (00: reserved) */
#define SCSI_DIR_IN 0x00000040 /* Data direction (01: DATA IN) */
#define SCSI_DIR_OUT 0x00000080 /* Data direction (10: DATA OUT) */
#define SCSI_DIR_NONE 0x000000C0 /* Data direction (11: no data) */
#define SCSI_DIR_MASK 0x000000C0
#define SCSI_DIS_AUTOSENSE 0x00000020 /* Disable autosense feature */
#define SCSI_ORDERED_QTAG 0x00000010 // ordered queue (cannot overtake/be overtaken)
#define SCSI_DMA_SAFE 0x00000008 // set if data buffer is DMA approved
#define SCSI_DIS_DISCONNECT 0x00008000 /* Disable disconnect */
#define SCSI_INITIATE_SYNC 0x00004000 /* Attempt Sync data xfer, and SDTR */
#define SCSI_DIS_SYNC 0x00002000 /* Disable sync, go to async */
#define SCSI_ENG_SYNC 0x00000200 /* Flush resid bytes before cmplt */
// Defines for the Path Inquiry CCB fields
// flags in hba_inquiry
#define SCSI_PI_MDP_ABLE 0x80 /* Supports MDP message */
#define SCSI_PI_WIDE_32 0x40 /* Supports 32 bit wide SCSI */
#define SCSI_PI_WIDE_16 0x20 /* Supports 16 bit wide SCSI */
#define SCSI_PI_SDTR_ABLE 0x10 /* Supports SDTR message */
#define SCSI_PI_TAG_ABLE 0x02 /* Supports tag queue message */
#define SCSI_PI_SOFT_RST 0x01 /* Supports soft reset */
// flags in hba_misc
#define SCSI_PIM_SCANHILO 0x80 /* Bus scans from ID 7 to ID 0 */
#define SCSI_PIM_NOREMOVE 0x40 /* Removable dev not included in scan */
// sizes of inquiry fields
#define SCSI_VUHBA 14 /* Vendor Unique HBA length */
#define SCSI_SIM_ID 16 /* ASCII string len for SIM ID */
#define SCSI_HBA_ID 16 /* ASCII string len for HBA ID */
#define SCSI_FAM_ID 16 /* ASCII string len for FAMILY ID */
#define SCSI_TYPE_ID 16 /* ASCII string len for TYPE ID */
#define SCSI_VERS 8 /* ASCII string len for SIM & HBA vers */
// Path inquiry, extended by BeOS XPT_EXTENDED_PATH_INQ parameters
typedef struct
{
uchar version_num; /* Version number for the SIM/HBA */
uchar hba_inquiry; /* Mimic of INQ byte 7 for the HBA */
uchar hba_misc; /* Misc HBA feature flags */
uint32 sim_priv; /* Size of SIM private data area */
uchar vuhba_flags[SCSI_VUHBA];/* Vendor unique capabilities */
uchar initiator_id; /* ID of the HBA on the SCSI bus */
uint32 hba_queue_size; // size of adapaters command queue
char sim_vid[SCSI_SIM_ID]; /* Vendor ID of the SIM */
char hba_vid[SCSI_HBA_ID]; /* Vendor ID of the HBA */
char sim_version[SCSI_VERS]; /* SIM version number */
char hba_version[SCSI_VERS]; /* HBA version number */
char controller_family[SCSI_FAM_ID]; /* Controller family */
char controller_type[SCSI_TYPE_ID]; /* Controller type */
} scsi_path_inquiry;
// Device node
// target (uint8)
#define SCSI_DEVICE_TARGET_ID_ITEM "scsi/target_id"
// lun (uint8)
#define SCSI_DEVICE_TARGET_LUN_ITEM "scsi/target_lun"
// node type
#define SCSI_DEVICE_TYPE_NAME "scsi/device/v1"
// device inquiry data (raw scsi_res_inquiry)
#define SCSI_DEVICE_INQUIRY_ITEM "scsi/device_inquiry"
// device type (uint8)
#define SCSI_DEVICE_TYPE_ITEM "scsi/type"
// vendor name (string)
#define SCSI_DEVICE_VENDOR_ITEM "scsi/vendor"
// product name (string)
#define SCSI_DEVICE_PRODUCT_ITEM "scsi/product"
// revision (string)
#define SCSI_DEVICE_REVISION_ITEM "scsi/revision"
// directory containing links to peripheral drivers
#define SCSI_PERIPHERAL_DRIVERS_DIR "scsi"
// bus manager device interface for peripheral driver
typedef struct scsi_device_interface {
driver_module_info info;
// get CCB
// warning: if pool of CCBs is exhausted, this call is delayed until a
// CCB is freed, so don't try to allocate more then one CCB at once!
scsi_ccb *(*alloc_ccb)(scsi_device device);
// free CCB
void (*free_ccb)(scsi_ccb *ccb);
// execute command asynchronously
// when it's finished, the semaphore of the ccb is released
// you must provide a S/G list if data_len != 0
void (*async_io)(scsi_ccb *ccb);
// execute command synchronously
// you don't need to provide a S/G list nor have to lock data
void (*sync_io)(scsi_ccb *ccb);
// abort request
uchar (*abort)(scsi_ccb *ccb_to_abort);
// reset device
uchar (*reset_device)(scsi_device device);
// terminate request
uchar (*term_io)(scsi_ccb *ccb_to_terminate);
} scsi_device_interface;
#define SCSI_DEVICE_MODULE_NAME "bus_managers/scsi/driver/v1"
// Bus node
// attributes:
// path (uint8)
#define SCSI_BUS_PATH_ID_ITEM "scsi/path_id"
// node type
#define SCSI_BUS_TYPE_NAME "scsi/bus"
// SCSI bus node driver.
// This interface can be used by peripheral drivers to access the
// bus directly.
typedef struct scsi_bus_interface {
bus_module_info info;
// get information about host controller
uchar (*path_inquiry)(scsi_bus bus, scsi_path_inquiry *inquiry_data);
// reset SCSI bus
uchar (*reset_bus)(scsi_bus bus);
} scsi_bus_interface;
// name of SCSI bus node driver
#define SCSI_BUS_MODULE_NAME "bus_managers/scsi/bus/v1"
// Interface for SIM
// cookie for dpc
typedef struct scsi_dpc_info *scsi_dpc_cookie;
// Bus manager interface used by SCSI controller drivers.
// SCSI controller drivers get this interface passed via their init_device
// method. Further, they must specify this driver as their fixed consumer.
typedef struct scsi_for_sim_interface {
driver_module_info info;
// put request into wait queue because of overflow
// bus_overflow: true - too many bus requests
// false - too many device requests
// bus/device won't receive requests until cont_sent_bus/cont_send_device
// is called or a request is finished via finished();
// to avoid race conditions (reporting a full and a available bus at once)
// the SIM should synchronize calls to requeue, resubmit and finished
void (*requeue)(scsi_ccb *ccb, bool bus_overflow);
// resubmit request ASAP
// to be used if execution of request went wrong and must be retried
void (*resubmit)(scsi_ccb *ccb);
// mark request as being finished
// num_requests: number of requests that were handled by device
// when the request was sent (read: how full was the device
// queue); needed to find out how large the device queue is;
// e.g. if three were already running plus this request makes
// num_requests=4
void (*finished)(scsi_ccb *ccb, uint num_requests);
// following functions return error on invalid arguments only
status_t (*alloc_dpc)(scsi_dpc_cookie *dpc);
status_t (*free_dpc)(scsi_dpc_cookie dpc);
status_t (*schedule_dpc)(scsi_bus cookie, scsi_dpc_cookie dpc, /*int flags,*/
void (*func)( void * ), void *arg);
// block entire bus (can be nested)
// no more request will be submitted to this bus
void (*block_bus)(scsi_bus bus);
// unblock entire bus
// requests will be submitted to bus ASAP
void (*unblock_bus)(scsi_bus bus);
// block one device
// no more requests will be submitted to this device
void (*block_device)(scsi_device device);
// unblock device
// requests for this device will be submitted ASAP
void (*unblock_device)(scsi_device device);
// terminate bus overflow condition (see "requeue")
void (*cont_send_bus)(scsi_bus bus);
// terminate device overflow condition (see "requeue")
void (*cont_send_device)(scsi_device device);
} scsi_for_sim_interface;
#define SCSI_FOR_SIM_MODULE_NAME "bus_managers/scsi/sim/v1"
// SIM Node
// attributes:
// node type
#define SCSI_SIM_TYPE_NAME "bus/scsi/v1"
// controller name (required, string)
#define SCSI_DESCRIPTION_CONTROLLER_NAME "controller_name"
typedef struct scsi_sim_cookie *scsi_sim_cookie;
// SIM interface
// SCSI controller drivers must provide this interface
typedef struct scsi_sim_interface {
driver_module_info info;
// execute request
void (*scsi_io)( scsi_sim_cookie cookie, scsi_ccb *ccb );
// abort request
uchar (*abort)( scsi_sim_cookie cookie, scsi_ccb *ccb_to_abort );
// reset device
uchar (*reset_device)( scsi_sim_cookie cookie, uchar target_id, uchar target_lun );
// terminate request
uchar (*term_io)( scsi_sim_cookie cookie, scsi_ccb *ccb_to_terminate );
// get information about bus
uchar (*path_inquiry)( scsi_sim_cookie cookie, scsi_path_inquiry *inquiry_data );
// scan bus
// this is called immediately before the SCSI bus manager scans the bus
uchar (*scan_bus)( scsi_sim_cookie cookie );
// reset bus
uchar (*reset_bus)( scsi_sim_cookie cookie );
// get restrictions of one device
// (used for non-SCSI transport protocols and bug fixes)
void (*get_restrictions)(
scsi_sim_cookie cookie,
uchar target_id, // target id
bool *is_atapi, // set to true if this is an ATAPI device that
// needs some commands emulated
bool *no_autosense, // set to true if there is no autosense;
// the SCSI bus manager will request sense on
// SCSI_REQ_CMP_ERR/SCSI_DEVICE_CHECK_CONDITION
uint32 *max_blocks ); // maximum number of blocks per transfer if > 0;
// used for buggy devices that cannot handle
// large transfers (read: ATAPI ZIP drives)
} scsi_sim_interface;
#endif /* __SCSI_BUSMANAGER_H__ */
@@ -0,0 +1,220 @@
/*
* Copyright 2005, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2002-04, Thomas Kurschel. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
#ifndef _IDE_PCI_H
#define _IDE_PCI_H
/*
IDE adapter library
Module to simplify writing an IDE adapter driver.
The interface is not very abstract, i.e. the actual driver is
free to access any controller or channel data of this library.
*/
#include <bus/PCI.h>
#include <bus/IDE.h>
#include <device_manager.h>
// one Physical Region Descriptor (PRD)
// (one region must not cross 64K boundary;
// the PRD table must not cross a 64K boundary)
typedef struct prd_entry {
uint32 address; // physical address of block (must be even)
uint16 count; // size of block, 0 stands for 65536 (must be even)
uint8 res6;
LBITFIELD8_2(
res7_0 : 7,
EOT : 1 // 1 for last entry
);
} prd_entry;
// command register
typedef struct ide_bm_command {
LBITFIELD8_4(
start_stop : 1, // start BM by changing from 0 to 1;
// stop BM by changing from 1 to 0
res0_1 : 2,
from_device : 1, // true - read from device, false - write to device
res0_4 : 4
);
} ide_bm_command;
// status register
typedef struct ide_bm_status {
LBITFIELD8_7(
active : 1, // 1, if BM is active
error : 1, // 1, if error occured; write 1 to reset
interrupt : 1, // 1, if INTRQ was raised, write 1 to reset
res0_3 : 2,
device0_dma : 1, // 1, if BIOS/driver has setup DMA for device 0
device1_dma : 1, // 1, if BIOS/driver has setup DMA for device 1
simplex : 1 // 1, if only one channel can use DMA at a time
);
} ide_bm_status;
// offset of bus master registers
enum {
ide_bm_command_reg = 0, // see ide_bm_command
ide_bm_status_reg = 2, // see ide_bm_status
ide_bm_prdt_address = 4 // offset of PRDT register; content must be dword-aligned
};
// bit mask in class_api of PCI configuration
// (for adapters that can run in compatability mode)
enum {
ide_api_primary_native = 1, // primary channel is in native mode
ide_api_primary_fixed = 2, // primary channel can be switched to native mode
ide_api_secondary_native = 4, // secondary channel is in native mode
ide_api_secondary_fixed = 8 // secondary channel can be switched to native mode
};
// (maximum) size of S/G table
// there are so many restrictions that we want to keep it inside one page
// to be sure that we fulfill them all
#define IDE_ADAPTER_MAX_SG_COUNT (B_PAGE_SIZE / sizeof( prd_entry ))
// channel node items
// io address of command block (uint16)
#define IDE_ADAPTER_COMMAND_BLOCK_BASE "ide_adapter/command_block_base"
// io address of control block (uint16)
#define IDE_ADAPTER_CONTROL_BLOCK_BASE "ide_adapter/control_block_base"
// interrupt number (uint8)
// can also be defined in controller node if both channels use same IRQ!
#define IDE_ADAPTER_INTNUM "ide_adapter/irq"
// non-zero if primary channel, else secondary channel (uint8)
#define IDE_ADAPTER_IS_PRIMARY "ide_adapter/is_primary"
// controller node items
// io address of bus master registers (uint16)
#define IDE_ADAPTER_BUS_MASTER_BASE "ide_adapter/bus_master_base"
// info about one channel
typedef struct ide_adapter_channel_info {
pci_device_module_info *pci;
pci_device device;
uint16 command_block_base; // io address command block
uint16 control_block_base; // io address control block
uint16 bus_master_base;
int intnum; // interrupt number
uint32 lost; // != 0 if device got removed, i.e. if it must not
// be accessed anymore
ide_channel ide_channel;
device_node_handle node;
int32 (*inthand)( void *arg );
area_id prd_area;
prd_entry *prdt;
uint32 prdt_phys;
uint32 dmaing;
} ide_adapter_channel_info;
// info about controller
typedef struct ide_adapter_controller_info {
pci_device_module_info *pci;
pci_device device;
uint16 bus_master_base;
uint32 lost; // != 0 if device got removed, i.e. if it must not
// be accessed anymore
device_node_handle node;
} ide_adapter_controller_info;
// interface of IDE adapter library
typedef struct {
module_info info;
// function calls that can be forwarded from actual driver
status_t (*write_command_block_regs)(ide_adapter_channel_info *channel,
ide_task_file *tf, ide_reg_mask mask);
status_t (*read_command_block_regs)(ide_adapter_channel_info *channel,
ide_task_file *tf, ide_reg_mask mask);
uint8 (*get_altstatus) (ide_adapter_channel_info *channel);
status_t (*write_device_control) (ide_adapter_channel_info *channel, uint8 val);
status_t (*write_pio)(ide_adapter_channel_info *channel, uint16 *data, int count, bool force_16bit);
status_t (*read_pio)(ide_adapter_channel_info *channel, uint16 *data, int count, bool force_16bit);
status_t (*prepare_dma)(ide_adapter_channel_info *channel, const physical_entry *sg_list,
size_t sg_list_count, bool to_device);
status_t (*start_dma)(ide_adapter_channel_info *channel);
status_t (*finish_dma)(ide_adapter_channel_info *channel);
// default functions that should be replaced by a more specific version
// (copy them from source code of this library and modify them at will)
int32 (*inthand)(void *arg);
// functions that must be called by init/uninit etc. of channel driver
status_t (*init_channel)(device_node_handle node, ide_channel ide_channel,
ide_adapter_channel_info **cookie, size_t total_data_size,
int32 (*inthand)(void *arg));
status_t (*uninit_channel)(ide_adapter_channel_info *channel);
void (*channel_removed)(device_node_handle node, ide_adapter_channel_info *channel);
// publish channel node
status_t (*publish_channel)(device_node_handle controller_node,
const char *channel_module_name, uint16 command_block_base,
uint16 control_block_base, uint8 intnum, bool can_dma,
bool is_primary, const char *name,
io_resource_handle *resources, device_node_handle *node);
// verify channel configuration and publish node on success
status_t (*detect_channel)(pci_device_module_info *pci, pci_device pci_device,
device_node_handle controller_node, const char *channel_module_name,
bool controller_can_dma, uint16 command_block_base,
uint16 control_block_base, uint16 bus_master_base,
uint8 intnum, bool is_primary, const char *name,
device_node_handle *node, bool supports_compatibility_mode);
// functions that must be called by init/uninit etc. of controller driver
status_t (*init_controller)(device_node_handle node, void *user_cookie,
ide_adapter_controller_info **cookie, size_t total_data_size);
status_t (*uninit_controller)(ide_adapter_controller_info *controller);
void (*controller_removed)(device_node_handle node, ide_adapter_controller_info *controller);
// publish controller node
status_t (*publish_controller)(device_node_handle parent, uint16 bus_master_base,
io_resource_handle *resources, const char *controller_driver,
const char *controller_driver_type, const char *controller_name,
bool can_dma, bool can_cq, uint32 dma_alignment, uint32 dma_boundary,
uint32 max_sg_block_size, device_node_handle *node);
// verify controller configuration and publish node on success
status_t (*detect_controller)(pci_device_module_info *pci, pci_device pci_device,
device_node_handle parent, uint16 bus_master_base,
const char *controller_driver, const char *controller_driver_type,
const char *controller_name, bool can_dma, bool can_cq,
uint32 dma_alignment, uint32 dma_boundary, uint32 max_sg_block_size,
device_node_handle *node);
// standard master probe for controller that registers controller and channel nodes
status_t (*probe_controller)(device_node_handle parent, const char *controller_driver,
const char *controller_driver_type, const char *controller_name,
const char *channel_module_name, bool can_dma, bool can_cq,
uint32 dma_alignment, uint32 dma_boundary, uint32 max_sg_block_size,
bool supports_compatibility_mode);
} ide_adapter_interface;
#define IDE_ADAPTER_MODULE_NAME "generic/ide_adapter/v1"
#endif /* _IDE_PCI_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,162 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
Part of Open SCSI Peripheral Driver
Use this module to minimize work required to write a SCSI
peripheral driver.
It takes care of:
- error handling
- medium changes (including restarting the medium)
- detection of medium capacity
*/
#ifndef __SCSI_PERIPH_H__
#define __SCSI_PERIPH_H__
#include <bus/SCSI.h>
#include <block_io.h>
#include <bus/scsi/scsi_cmds.h>
#include <Drivers.h>
// cookie issued by module per device
typedef struct scsi_periph_device_info *scsi_periph_device;
// cookie issued by module per file handle
typedef struct scsi_periph_handle_info *scsi_periph_handle;
// "standardized" error code to simplify handling of scsi errors
typedef enum {
err_act_ok, // executed successfully
err_act_retry, // failed, retry 3 times
err_act_fail, // failed, don't retry
err_act_many_retries, // failed, retry multiple times (currently 10 times)
err_act_start, // devices requires a "start" command
err_act_invalid_req // request is invalid
} err_act;
// packed scsi command result
typedef struct err_res {
status_t error_code : 32; // Be error code
uint32 action : 8; // err_act code
} err_res;
#define MK_ERROR( aaction, code ) ({ \
err_res res = {error_code: (code), action: (aaction) }; \
res; \
})
// device icon type
typedef enum {
icon_type_disk,
icon_type_removal,
icon_type_floppy,
icon_type_cd
} icon_type;
// cookie issued by driver to identify itself
//typedef struct periph_info *periph_cookie;
// cookie issued by driver per device
typedef struct periph_device_info *periph_device_cookie;
// cookie issued by driver per file handle
typedef struct periph_handle_info *periph_handle_cookie;
// callbacks to be provided by peripheral driver
typedef struct scsi_periph_callbacks {
// *** block devices ***
// informs of new size of medium
// (set to NULL if not a block device)
void (*set_capacity)( periph_device_cookie periph_device, uint64 capacity,
uint32 block_size );
// *** removable devices
// called when media got changed (can be NULL if medium is not changable)
// (you don't need to call periph->media_changed, but it's doesn't if you do)
// ccb - request at your disposal
void (*media_changed)( periph_device_cookie periph_device,
scsi_ccb *request );
} scsi_periph_callbacks;
// functions provided by this module
typedef struct scsi_periph_interface {
module_info info;
// *** init/cleanup ***
status_t (*register_device)(
periph_device_cookie periph_device,
scsi_periph_callbacks *callbacks,
scsi_device scsi_device,
scsi_device_interface *scsi,
device_node_handle node,
bool removable,
scsi_periph_device *driver );
status_t (*unregister_device)( scsi_periph_device driver );
// *** basic command execution ***
// exec command, retrying on problems
status_t (*safe_exec)(
scsi_periph_device periph_device,
scsi_ccb *request );
// exec simple command
status_t (*simple_exec)( scsi_periph_device device,
void *cdb, uchar cdb_len, void *data, size_t data_len,
int ccb_flags );
// *** file handling ***
// to be called when a new file is opened
status_t (*handle_open)( scsi_periph_device device,
periph_handle_cookie periph_handle, scsi_periph_handle *res_handle );
// to be called when a file is closed
status_t (*handle_close)( scsi_periph_handle handle );
// to be called when a file is freed
status_t (*handle_free)( scsi_periph_handle handle );
// *** default implementation for block devices ***
// block read
// preferred_ccb_size - preferred command size; if zero, the shortest is used
status_t (*read)( scsi_periph_handle handle, const phys_vecs *vecs,
off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred,
int preferred_ccb_size );
// block write
// (see block_read)
status_t (*write)( scsi_periph_handle handle, const phys_vecs *vecs,
off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred,
int preferred_ccb_size );
// block ioctls
status_t (*ioctl)( scsi_periph_handle handle, int op, void *buf, size_t len );
// check medium capacity (calls set_capacity callback on success)
// request - ccb for this device; is used to talk to device
status_t (*check_capacity)( scsi_periph_device device, scsi_ccb *request );
// *** removable media ***
// to be called when a medium change is detected to block subsequent commands
void (*media_changed)( scsi_periph_device device );
// convert result of *request to err_res
err_res (*check_error)( scsi_periph_device device, scsi_ccb *request );
// send start or stop command to device
// with_LoEj = true - include loading/ejecting,
// false - only do allow/deny
err_res (*send_start_stop)( scsi_periph_device device, scsi_ccb *request,
bool start, bool with_LoEj );
// checks media status and waits for device to become ready
// returns: B_OK, B_DEV_MEDIA_CHANGE_REQUESTED, B_NO_MEMORY or
// pending error reported by handle_get_error
status_t (*get_media_status)( scsi_periph_handle handle );
// compose device name consisting of prefix and path/target/LUN
// (result must be freed by caller)
char *(*compose_device_name)(device_node_handle device_node, const char *prefix);
// fill data with icon (for B_GET_ICON ioctl)
status_t (*get_icon)( icon_type type, device_icon *data );
} scsi_periph_interface;
#define SCSI_PERIPH_MODULE_NAME "generic/scsi_periph/v1"
#endif
+31
View File
@@ -0,0 +1,31 @@
/*******************************************************************************
/
/ File: bus_managers.h
/
/ Description: bus manager API
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _BUS_MANAGER_H
#define _BUS_MANAGER_H
#include <module.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct bus_manager_info bus_manager_info;
struct bus_manager_info {
module_info minfo;
status_t (*rescan)();
};
#ifdef __cplusplus
}
#endif
#endif /* _BUS_MANAGER_H */
+115
View File
@@ -0,0 +1,115 @@
#ifndef _CONFIG_MANAGER_H
#define _CONFIG_MANAGER_H
#include <module.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
B_ISA_BUS,
B_PCI_BUS,
B_PCMCIA_BUS,
B_UNKNOWN_BUS = 0x80
} bus_type;
typedef struct {
uchar base;
uchar subtype;
uchar interface;
} device_type;
typedef struct {
uint32 mask;
uint32 flags;
uint32 cookie;
} resource_mask_descriptor;
typedef struct {
uint32 minbase;
uint32 maxbase;
uint32 basealign;
uint32 len;
uint32 flags;
uint32 cookie;
} resource_range_descriptor;
typedef enum {
B_IRQ_RESOURCE,
B_DMA_RESOURCE,
B_IO_PORT_RESOURCE,
B_MEMORY_RESOURCE
} resource_type;
typedef struct {
resource_type type;
union {
resource_mask_descriptor m;
resource_range_descriptor r;
uint32 for_padding[7];
} d;
} resource_descriptor;
struct device_configuration {
uint32 flags;
uint32 num_resources;
resource_descriptor resources[0];
};
struct possible_device_configurations {
uint32 flags;
uint32 num_possible;
struct device_configuration possible[0];
};
struct device_info {
uint32 size;
uint32 bus_dependent_info_offset;
bus_type bus;
device_type devtype;
uint32 id[4]; /* unique (per-bus) normally-persistent id for device */
uint32 flags;
status_t config_status;
/* bus-dependent data goes here... */
};
#define B_DEVICE_INFO_ENABLED 1
#define B_DEVICE_INFO_CONFIGURED 2
#define B_DEVICE_INFO_CAN_BE_DISABLED 4
typedef struct config_manager_for_driver_module_info {
module_info minfo;
status_t (*get_next_device_info)(bus_type bus, uint64 *cookie,
struct device_info *info, uint32 len);
status_t (*get_device_info_for)(uint64 device,
struct device_info *info, uint32 len);
status_t (*get_size_of_current_configuration_for)(uint64 device);
status_t (*get_current_configuration_for)(uint64 device,
struct device_configuration *config, uint32 len);
status_t (*get_size_of_possible_configurations_for)(uint64 device);
status_t (*get_possible_configurations_for)(uint64 device,
struct possible_device_configurations *possible,
uint32 len);
/* helper routines for drivers */
status_t (*count_resource_descriptors_of_type)(
const struct device_configuration *config,
resource_type type);
status_t (*get_nth_resource_descriptor_of_type)(
const struct device_configuration *config, uint32 n,
resource_type type, resource_descriptor *descriptor,
uint32 len);
} config_manager_for_driver_module_info;
#define B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME "bus_managers/config_manager/driver/v1"
#ifdef __cplusplus
}
#endif
#endif /* _CONFIG_MANAGER_H */
+197
View File
@@ -0,0 +1,197 @@
/*
* Copyright 2004-2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT license.
*/
#ifndef _DEVICE_MANAGER_H
#define _DEVICE_MANAGER_H
#include <TypeConstants.h>
#include <Drivers.h>
#include <module.h>
// type of I/O resource
enum {
IO_MEM = 1,
IO_PORT = 2,
ISA_DMA_CHANNEL = 3
};
// I/O resource description
typedef struct {
uint32 type;
// type of I/O resource
uint32 base;
// I/O memory: first physical address (32 bit)
// I/O port: first port address (16 bit)
// ISA DMA channel: channel number (0-7)
uint32 length;
// I/O memory: size of address range (32 bit)
// I/O port: size of port range (16 bit)
// ISA DMA channel: must be 1
} io_resource;
// attribute of a device node
typedef struct {
const char *name;
type_code type; // for supported types, see value
union {
uint8 ui8; // B_UINT8_TYPE
uint16 ui16; // B_UINT16_TYPE
uint32 ui32; // B_UINT32_TYPE
uint64 ui64; // B_UINT64_TYPE
const char *string; // B_STRING_TYPE
struct { // B_RAW_TYPE
void *data;
size_t length;
} raw;
} value;
} device_attr;
typedef struct device_node_info *device_node_handle;
typedef struct io_resource_info *io_resource_handle;
typedef struct device_attr_info *device_attr_handle;
typedef struct driver_module_info driver_module_info;
// interface of the device manager
typedef struct device_manager_info {
module_info info;
status_t (*init_driver)(device_node_handle node, void *userCookie,
driver_module_info **interface, void **cookie);
status_t (*uninit_driver)(device_node_handle node);
status_t (*rescan)(device_node_handle node);
status_t (*register_device)(device_node_handle parent,
const device_attr *attrs,
const io_resource_handle *io_resources,
device_node_handle *node);
status_t (*unregister_device)(device_node_handle node);
status_t (*get_next_child_device)(device_node_handle parent,
device_node_handle *_node, const device_attr *attrs);
device_node_handle (*get_parent)(device_node_handle node);
void (*put_device_node)(device_node_handle node);
status_t (*acquire_io_resources)(io_resource *resources,
io_resource_handle *handles);
status_t (*release_io_resources)(const io_resource_handle *handles);
int32 (*create_id)(const char *generator);
status_t (*free_id)(const char *generator, uint32 id);
status_t (*get_attr_uint8)(device_node_handle node,
const char *name, uint8 *value, bool recursive);
status_t (*get_attr_uint16)(device_node_handle node,
const char *name, uint16 *value, bool recursive);
status_t (*get_attr_uint32)(device_node_handle node,
const char *name, uint32 *value, bool recursive);
status_t (*get_attr_uint64)(device_node_handle node,
const char *name, uint64 *value, bool recursive);
status_t (*get_attr_string)(device_node_handle node,
const char *name, char **value, bool recursive);
status_t (*get_attr_raw)(device_node_handle node,
const char *name, void **data, size_t *_size,
bool recursive);
status_t (*get_next_attr)(device_node_handle node,
device_attr_handle *attrHandle);
status_t (*release_attr)(device_node_handle node,
device_attr_handle attr_handle);
status_t (*retrieve_attr)(device_attr_handle attr_handle,
const device_attr **attr);
status_t (*write_attr)(device_node_handle node,
const device_attr *attr);
status_t (*remove_attr)(device_node_handle node, const char *name);
} device_manager_info;
#define B_DEVICE_MANAGER_MODULE_NAME "system/device_manager/v1"
// interface of device driver
struct driver_module_info {
module_info info;
float (*supports_device)(device_node_handle parent, bool *_noConnection);
status_t (*register_device)(device_node_handle parent);
status_t (*init_driver)(device_node_handle node, void *user_cookie, void **_cookie);
status_t (*uninit_driver)(void *cookie);
void (*device_removed)(device_node_handle node, void *cookie);
void (*device_cleanup)(device_node_handle node);
void (*get_supported_paths)(const char ***_busses, const char ***_devices);
};
// standard device node attributes
#define PNP_MANAGER_ID_GENERATOR "id_generator"
// if you are using an id generator (see create_id), you can let the
// manager automatically free the id when the node is deleted by setting
// the following attributes:
// name of generator (string)
#define PNP_MANAGER_AUTO_ID "auto_id"
// generated id (uint32)
#define B_DRIVER_MODULE "driver/module"
#define B_DRIVER_PRETTY_NAME "driver/pretty name"
#define B_DRIVER_FIXED_CHILD "driver/fixed child"
#define B_DRIVER_MAPPING "driver/mapping"
#define B_DRIVER_BUS "driver/bus"
#define B_DRIVER_FIND_DEVICES_ON_DEMAND "driver/on demand"
#define B_DRIVER_EXPLORE_LAST "driver/explore last"
#define B_DRIVER_UNIQUE_DEVICE_ID "unique id"
#define B_DRIVER_DEVICE_TYPE "device type"
#define B_AUDIO_DRIVER_TYPE "audio"
#define B_BUS_DRIVER_TYPE "bus"
#define B_DISK_DRIVER_TYPE "disk"
#define B_GRAPHICS_DRIVER_TYPE "graphics"
#define B_INPUT_DRIVER_TYPE "input"
#define B_MISC_DRIVER_TYPE "misc"
#define B_NETWORK_DRIVER_TYPE "net"
#define B_VIDEO_DRIVER_TYPE "video"
#define PNP_DRIVER_CONNECTION "connection"
// connection of parent the device is attached to (optional, string)
// there can be only one device per connection
// interface of a bus device driver
typedef struct bus_module_info {
driver_module_info info;
// scan the bus and register all devices.
status_t (*register_child_devices)(void *cookie);
// user initiated rescan of the bus - only propagate changes
// you only need to implement this, if you cannot detect device changes yourself
// driver is always loaded during this call, but other hooks may
// be called concurrently
status_t (*rescan_bus)(void *cookie);
} bus_module_info;
// standard attributes
// PnP bus identification (required, uint8)
// define this to let the PnP manager know that this is a PnP bus
// the actual content is ignored
#define PNP_BUS_IS_BUS "bus/is_bus"
#endif /* _DEVICE_MANAGER_H */
@@ -0,0 +1,126 @@
// disk_device_manager.h
//
// C API exported by the disk device manager.
// Currently only functions of interest for partition modules/FS add-ons
// are considered.
#ifndef _DISK_DEVICE_MANAGER_H
#define _DISK_DEVICE_MANAGER_H
#include <Drivers.h>
#include <storage/DiskDeviceDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
// C API partition representation
// Fields marked [sys] are set by the system and are not to be changed by
// the disk system modules.
typedef struct partition_data {
partition_id id; // [sys]
off_t offset;
off_t size;
off_t content_size;
uint32 block_size;
int32 child_count;
int32 index; // [sys]
uint32 status;
uint32 flags;
dev_t volume; // [sys]
void *mount_cookie; // [sys]
char *name; // max: B_OS_NAME_LENGTH
char *content_name; //
char *type; //
const char *content_type; // [sys]
char *parameters;
char *content_parameters;
void *cookie;
void *content_cookie;
} partition_data;
// C API disk device representation
typedef struct disk_device_data {
partition_id id; // equal to that of the root partition
uint32 flags;
char *path;
device_geometry geometry;
} disk_device_data;
// C API partitionable space representation
typedef struct partitionable_space_data {
off_t offset;
off_t size;
} partitionable_space_data;
// operations on partitions
enum {
B_PARTITION_DEFRAGMENT,
B_PARTITION_REPAIR,
B_PARTITION_RESIZE,
B_PARTITION_RESIZE_CHILD,
B_PARTITION_MOVE,
B_PARTITION_MOVE_CHILD,
B_PARTITION_SET_NAME,
B_PARTITION_SET_CONTENT_NAME,
B_PARTITION_SET_TYPE,
B_PARTITION_SET_PARAMETERS,
B_PARTITION_SET_CONTENT_PARAMETERS,
B_PARTITION_INITIALIZE,
B_PARTITION_CREATE_CHILD,
B_PARTITION_DELETE_CHILD,
};
// disk device job cancel status
enum {
B_DISK_DEVICE_JOB_CONTINUE,
B_DISK_DEVICE_JOB_CANCEL,
B_DISK_DEVICE_JOB_REVERSE,
};
// disk device locking
disk_device_data *write_lock_disk_device(partition_id partitionID);
void write_unlock_disk_device(partition_id partitionID);
disk_device_data *read_lock_disk_device(partition_id partitionID);
void read_unlock_disk_device(partition_id partitionID);
// parameter is the ID of any partition on the device
// getting disk devices/partitions by path
// (no locking required)
int32 find_disk_device(const char *path);
int32 find_partition(const char *path);
// disk device/partition read access
// (read lock required)
disk_device_data *get_disk_device(partition_id partitionID);
partition_data *get_partition(partition_id partitionID);
partition_data *get_parent_partition(partition_id partitionID);
partition_data *get_child_partition(partition_id partitionID, int32 index);
// partition write access
// (write lock required)
partition_data *create_child_partition(partition_id partitionID, int32 index,
partition_id childID);
// childID is an optional input parameter -- -1 to be ignored
bool delete_partition(partition_id partitionID);
void partition_modified(partition_id partitionID);
// tells the disk device manager, that the parition has been modified
// disk systems
disk_system_id find_disk_system(const char *name);
// jobs
bool update_disk_device_job_progress(disk_job_id jobID, float progress);
bool update_disk_device_job_extra_progress(disk_job_id jobID,
const char *info);
bool set_disk_device_job_error_message(disk_job_id jobID, const char *message);
uint32 update_disk_device_job_interrupt_properties(disk_job_id jobID,
uint32 interruptProperties);
// returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE}
#ifdef __cplusplus
}
#endif
#endif // _DISK_DEVICE_MANAGER_H
@@ -0,0 +1,52 @@
#ifndef _DRIVER_SETTINGS_H
#define _DRIVER_SETTINGS_H
#include <OS.h>
typedef struct driver_parameter {
char *name;
int value_count;
char **values;
int parameter_count;
struct driver_parameter *parameters;
} driver_parameter;
typedef struct driver_settings {
int parameter_count;
struct driver_parameter *parameters;
} driver_settings;
#ifdef __cplusplus
extern "C" {
#endif
extern void *load_driver_settings(const char *driverName);
extern status_t unload_driver_settings(void *handle);
extern void *parse_driver_settings_string(const char *settingsString);
extern status_t get_driver_settings_string(void *_handle, char *buffer,
size_t *_bufferSize, bool flat);
extern status_t delete_driver_settings(void *handle);
extern const char *get_driver_parameter(void *handle, const char *key,
const char *unknownValue, /* key not present */
const char *noargValue); /* key has no value */
extern bool get_driver_boolean_parameter(void *handle, const char *key,
bool unknownValue, bool noargValue);
extern const driver_settings *get_driver_settings(void *handle);
/* Pass this in as drivername to access safe mode settings */
#define B_SAFEMODE_DRIVER_SETTINGS "/safemode/"
/* Pass this as the key value to check if safe mode is enabled */
#define B_SAFEMODE_SAFE_MODE "safemode"
#ifdef __cplusplus
}
#endif
#endif /* _DRIVER_SETTINGS_H */
+80
View File
@@ -0,0 +1,80 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
Fast logging facilities.
This logging is much faster then dprintf and is saver
against buffer overflow conditions.
Clients have to define events by creating an array of
fast_log_type entries, each consisting of a code and the
associated human-readable description. During logging,
only the code is stored to save space and time. Also,
all arguments are stored binary (currently, they must
be of type uint32). Conversion to human-readable text is
post-poned until the logging data is read or a client
connection is closed (as this invalidates the event-
description binding).
The reader interface is /dev/FAST_LOG_DEVFS_NAME. This
device can only be read from (no seeking or further
functionality) and does not block if there is no data.
This is because if you want to store the log into a
file, the file access may lead to further logging data,
so doing a sleep between reads saves logging entries.
*/
#ifndef FAST_LOG_H
#define FAST_LOG_H
#include <module.h>
// one event type as defined by client
typedef struct fast_log_event_type {
// code of event (zero means end-of-list)
int16 event;
// human-readable description
const char *description;
} fast_log_event_type;
// handle of client connection
typedef struct fast_log_connection *fast_log_handle;
// client interface
typedef struct fast_log_info {
module_info minfo;
// open client connection
// prefix - prefix to print in log before each event
// types - array of event types; last entry must have event=0
fast_log_handle (*start_log)(const char *prefix, fast_log_event_type types[]);
// close client connection
void (*stop_log)(fast_log_handle handle);
// log an entry without arguments
void (*log_0)(fast_log_handle handle, int event);
// log an entry with one argument
void (*log_1)(fast_log_handle handle, int event, uint32 param1);
// log an entry with two arguments
void (*log_2)(fast_log_handle handle, int event, uint32 param1, uint32 param2);
// log an entry with three arguments
void (*log_3)(fast_log_handle handle, int event, uint32 param1, uint32 param2, uint32 param3);
// log an entry with four arguments
void (*log_4)(fast_log_handle handle, int event, uint32 param1, uint32 param2, uint32 param3, uint32 param4);
// log an entry with n arguments
// don't cheat on num_params!
void (*log_n)(fast_log_handle handle, int event, int num_params, ...);
} fast_log_info;
// name of client interface module
#define FAST_LOG_MODULE_NAME "generic/fast_log/v1"
// name of device to read logging data from
#define FAST_LOG_DEVFS_NAME "fast_log"
#endif
+63
View File
@@ -0,0 +1,63 @@
/* File System File and Block Caches
*
* Copyright 2004-2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FS_CACHE_H
#define _FS_CACHE_H
#include <fs_interface.h>
typedef void (*transaction_notification_hook)(int32 id, void *data);
#ifdef __cplusplus
extern "C" {
#endif
/* transactions */
extern int32 cache_start_transaction(void *_cache);
extern status_t cache_sync_transaction(void *_cache, int32 id);
extern status_t cache_end_transaction(void *_cache, int32 id, transaction_notification_hook hook, void *data);
extern status_t cache_abort_transaction(void *_cache, int32 id);
extern int32 cache_detach_sub_transaction(void *_cache, int32 id);
extern status_t cache_abort_sub_transaction(void *_cache, int32 id);
extern status_t cache_start_sub_transaction(void *_cache, int32 id);
extern status_t cache_next_block_in_transaction(void *_cache, int32 id, uint32 *_cookie,
off_t *_blockNumber, void **_data, void **_unchangedData);
/* block cache */
extern void block_cache_delete(void *_cache, bool allowWrites);
extern void *block_cache_create(int fd, off_t numBlocks, size_t blockSize);
extern status_t block_cache_sync(void *_cache);
extern status_t block_cache_make_writable(void *_cache, off_t blockNumber, int32 transaction);
extern void *block_cache_get_writable_etc(void *_cache, off_t blockNumber, off_t base,
off_t length, int32 transaction);
extern void *block_cache_get_writable(void *_cache, off_t blockNumber, int32 transaction);
extern void *block_cache_get_empty(void *_cache, off_t blockNumber, int32 transaction);
extern const void *block_cache_get_etc(void *_cache, off_t blockNumber, off_t base, off_t length);
extern const void *block_cache_get(void *_cache, off_t blockNumber);
extern status_t block_cache_set_dirty(void *_cache, off_t blockNumber, bool isDirty, int32 transaction);
extern void block_cache_put(void *_cache, off_t blockNumber);
/* file cache */
extern void *file_cache_create(mount_id mountID, vnode_id vnodeID, off_t size, int fd);
extern void file_cache_delete(void *_cacheRef);
extern status_t file_cache_set_size(void *_cacheRef, off_t size);
extern status_t file_cache_sync(void *_cache);
extern status_t file_cache_invalidate_file_map(void *_cacheRef, off_t offset, off_t size);
extern status_t file_cache_read_pages(void *_cacheRef, off_t offset,
const iovec *vecs, size_t count, size_t *_numBytes);
extern status_t file_cache_write_pages(void *_cacheRef, off_t offset,
const iovec *vecs, size_t count, size_t *_numBytes);
extern status_t file_cache_read(void *_cacheRef, off_t offset, void *bufferBase, size_t *_size);
extern status_t file_cache_write(void *_cacheRef, off_t offset, const void *buffer, size_t *_size);
#ifdef __cplusplus
}
#endif
#endif /* _FS_CACHE_H */
+258
View File
@@ -0,0 +1,258 @@
/* File System Interface Layer Definition
*
* Copyright 2004-2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FS_INTERFACE_H
#define _FS_INTERFACE_H
#include <OS.h>
#include <Select.h>
#include <module.h>
#include <disk_device_manager.h>
#include <sys/uio.h>
struct dirent;
struct stat;
struct fs_info;
struct select_sync;
typedef dev_t mount_id;
typedef ino_t vnode_id;
/* the file system's private data structures */
typedef void *fs_volume;
typedef void *fs_cookie;
typedef void *fs_vnode;
/* passed to write_stat() */
enum write_stat_mask {
FS_WRITE_STAT_MODE = 0x0001,
FS_WRITE_STAT_UID = 0x0002,
FS_WRITE_STAT_GID = 0x0004,
FS_WRITE_STAT_SIZE = 0x0008,
FS_WRITE_STAT_ATIME = 0x0010,
FS_WRITE_STAT_MTIME = 0x0020,
FS_WRITE_STAT_CRTIME = 0x0040
// NOTE: Changing these constants will break
// src/kits/storage/LibBeAdapter.cpp:_kern_write_stat().
};
/* passed to write_fs_info() */
#define FS_WRITE_FSINFO_NAME 0x0001
struct file_io_vec {
off_t offset;
off_t length;
};
#define B_CURRENT_FS_API_VERSION "/v1"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct file_system_module_info {
struct module_info info;
const char *pretty_name;
/* scanning (the device is write locked) */
float (*identify_partition)(int fd, partition_data *partition,
void **cookie);
status_t (*scan_partition)(int fd, partition_data *partition,
void *cookie);
void (*free_identify_partition_cookie)(partition_data *partition,
void *cookie);
void (*free_partition_content_cookie)(partition_data *partition);
/* general operations */
status_t (*mount)(mount_id id, const char *device, uint32 flags,
const char *args, fs_volume *_fs, vnode_id *_rootVnodeID);
status_t (*unmount)(fs_volume fs);
status_t (*read_fs_info)(fs_volume fs, struct fs_info *info);
status_t (*write_fs_info)(fs_volume fs, const struct fs_info *info, uint32 mask);
status_t (*sync)(fs_volume fs);
/* vnode operations */
status_t (*lookup)(fs_volume fs, fs_vnode dir, const char *name, vnode_id *_id, int *_type);
status_t (*get_vnode_name)(fs_volume fs, fs_vnode vnode, char *buffer, size_t bufferSize);
status_t (*get_vnode)(fs_volume fs, vnode_id id, fs_vnode *_vnode, bool reenter);
status_t (*put_vnode)(fs_volume fs, fs_vnode vnode, bool reenter);
status_t (*remove_vnode)(fs_volume fs, fs_vnode vnode, bool reenter);
/* VM file access */
bool (*can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*read_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes);
status_t (*write_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes);
/* cache file access */
status_t (*get_file_map)(fs_volume fs, fs_vnode vnode, off_t offset, size_t size, struct file_io_vec *vecs, size_t *_count);
/* common operations */
status_t (*ioctl)(fs_volume fs, fs_vnode v, fs_cookie cookie, ulong op, void *buffer, size_t length);
status_t (*set_flags)(fs_volume fs, fs_vnode v, fs_cookie cookie, int flags);
status_t (*select)(fs_volume fs, fs_vnode v, fs_cookie cookie, uint8 event,
uint32 ref, selectsync *sync);
status_t (*deselect)(fs_volume fs, fs_vnode v, fs_cookie cookie,
uint8 event, selectsync *sync);
status_t (*fsync)(fs_volume fs, fs_vnode v);
status_t (*read_link)(fs_volume fs, fs_vnode link, char *buffer, size_t *_bufferSize);
status_t (*write_link)(fs_volume fs, fs_vnode link, char *toPath);
status_t (*create_symlink)(fs_volume fs, fs_vnode dir, const char *name, const char *path, int mode);
status_t (*link)(fs_volume fs, fs_vnode dir, const char *name, fs_vnode vnode);
status_t (*unlink)(fs_volume fs, fs_vnode dir, const char *name);
status_t (*rename)(fs_volume fs, fs_vnode fromDir, const char *fromName, fs_vnode toDir, const char *toName);
status_t (*access)(fs_volume fs, fs_vnode vnode, int mode);
status_t (*read_stat)(fs_volume fs, fs_vnode vnode, struct stat *stat);
status_t (*write_stat)(fs_volume fs, fs_vnode vnode, const struct stat *stat, uint32 statMask);
/* file operations */
status_t (*create)(fs_volume fs, fs_vnode dir, const char *name, int openMode, int perms, fs_cookie *_cookie, vnode_id *_newVnodeID);
status_t (*open)(fs_volume fs, fs_vnode v, int openMode, fs_cookie *_cookie);
status_t (*close)(fs_volume fs, fs_vnode v, fs_cookie cookie);
status_t (*free_cookie)(fs_volume fs, fs_vnode v, fs_cookie cookie);
status_t (*read)(fs_volume fs, fs_vnode v, fs_cookie cookie, off_t pos, void *buffer, size_t *length);
status_t (*write)(fs_volume fs, fs_vnode v, fs_cookie cookie, off_t pos, const void *buffer, size_t *length);
/* directory operations */
status_t (*create_dir)(fs_volume fs, fs_vnode parent, const char *name, int perms, vnode_id *_newVnodeID);
status_t (*remove_dir)(fs_volume fs, fs_vnode parent, const char *name);
status_t (*open_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie);
status_t (*close_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*free_dir_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*read_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num);
status_t (*rewind_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
/* attribute directory operations */
status_t (*open_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie);
status_t (*close_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*free_attr_dir_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
status_t (*read_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num);
status_t (*rewind_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
/* attribute operations */
status_t (*create_attr)(fs_volume fs, fs_vnode file, const char *name, uint32 type, int openMode, fs_cookie *_cookie);
status_t (*open_attr)(fs_volume fs, fs_vnode file, const char *name, int openMode, fs_cookie *_cookie);
status_t (*close_attr)(fs_volume fs, fs_vnode file, fs_cookie cookie);
status_t (*free_attr_cookie)(fs_volume fs, fs_vnode file, fs_cookie cookie);
status_t (*read_attr)(fs_volume fs, fs_vnode file, fs_cookie cookie, off_t pos, void *buffer, size_t *length);
status_t (*write_attr)(fs_volume fs, fs_vnode file, fs_cookie cookie, off_t pos, const void *buffer, size_t *length);
status_t (*read_attr_stat)(fs_volume fs, fs_vnode file, fs_cookie cookie, struct stat *stat);
status_t (*write_attr_stat)(fs_volume fs, fs_vnode file, fs_cookie cookie, const struct stat *stat, int statMask);
status_t (*rename_attr)(fs_volume fs, fs_vnode fromFile, const char *fromName, fs_vnode toFile, const char *toName);
status_t (*remove_attr)(fs_volume fs, fs_vnode file, const char *name);
/* index directory & index operations */
status_t (*open_index_dir)(fs_volume fs, fs_cookie *cookie);
status_t (*close_index_dir)(fs_volume fs, fs_cookie cookie);
status_t (*free_index_dir_cookie)(fs_volume fs, fs_cookie cookie);
status_t (*read_index_dir)(fs_volume fs, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num);
status_t (*rewind_index_dir)(fs_volume fs, fs_cookie cookie);
status_t (*create_index)(fs_volume fs, const char *name, uint32 type, uint32 flags);
status_t (*remove_index)(fs_volume fs, const char *name);
status_t (*read_index_stat)(fs_volume fs, const char *name, struct stat *stat);
/* query operations */
status_t (*open_query)(fs_volume fs, const char *query, uint32 flags, port_id port, uint32 token, fs_cookie *_cookie);
status_t (*close_query)(fs_volume fs, fs_cookie cookie);
status_t (*free_query_cookie)(fs_volume fs, fs_cookie cookie);
status_t (*read_query)(fs_volume fs, fs_cookie cookie,
struct dirent *buffer, size_t bufferSize, uint32 *_num);
status_t (*rewind_query)(fs_volume fs, fs_cookie cookie);
/* capability querying (the device is read locked) */
// ToDo: this will probably be combined to a single call
bool (*supports_defragmenting)(partition_data *partition,
bool *whileMounted);
bool (*supports_repairing)(partition_data *partition,
bool checkOnly, bool *whileMounted);
bool (*supports_resizing)(partition_data *partition,
bool *whileMounted);
bool (*supports_moving)(partition_data *partition, bool *isNoOp);
bool (*supports_setting_content_name)(partition_data *partition,
bool *whileMounted);
bool (*supports_setting_content_parameters)(partition_data *partition,
bool *whileMounted);
bool (*supports_initializing)(partition_data *partition);
bool (*validate_resize)(partition_data *partition, off_t *size);
bool (*validate_move)(partition_data *partition, off_t *start);
bool (*validate_set_content_name)(partition_data *partition,
char *name);
bool (*validate_set_content_parameters)(partition_data *partition,
const char *parameters);
bool (*validate_initialize)(partition_data *partition, char *name,
const char *parameters);
/* shadow partition modification (device is write locked) */
status_t (*shadow_changed)(partition_data *partition,
uint32 operation);
/* writing (the device is NOT locked) */
status_t (*defragment)(int fd, partition_id partition,
disk_job_id job);
status_t (*repair)(int fd, partition_id partition, bool checkOnly,
disk_job_id job);
status_t (*resize)(int fd, partition_id partition, off_t size,
disk_job_id job);
status_t (*move)(int fd, partition_id partition, off_t offset,
disk_job_id job);
status_t (*set_content_name)(int fd, partition_id partition,
const char *name, disk_job_id job);
status_t (*set_content_parameters)(int fd, partition_id partition,
const char *parameters, disk_job_id job);
status_t (*initialize)(const char *partition, const char *name,
const char *parameters, disk_job_id job);
// This is pretty close to how the hook in R5 looked. Save the job ID, of
// course and that the parameters were given as (void*, size_t) pair.
} file_system_module_info;
/* file system add-ons only prototypes */
extern status_t new_vnode(mount_id mountID, vnode_id vnodeID, fs_vnode privateNode);
extern status_t publish_vnode(mount_id mountID, vnode_id vnodeID, fs_vnode privateNode);
extern status_t get_vnode(mount_id mountID, vnode_id vnodeID, fs_vnode *_privateNode);
extern status_t put_vnode(mount_id mountID, vnode_id vnodeID);
extern status_t remove_vnode(mount_id mountID, vnode_id vnodeID);
extern status_t unremove_vnode(mount_id mountID, vnode_id vnodeID);
extern status_t notify_listener(int op, mount_id device, vnode_id parentNode,
vnode_id toParentNode, vnode_id node, const char *name);
extern status_t send_notification(port_id port, long token, ulong what, long op,
mount_id device, mount_id toDevice, vnode_id parentNode,
vnode_id toParentNode, vnode_id node, const char *name);
extern status_t notify_entry_created(mount_id device, vnode_id directory,
const char *name, vnode_id node);
extern status_t notify_entry_removed(mount_id device, vnode_id directory,
const char *name, vnode_id node);
extern status_t notify_entry_moved(mount_id device, vnode_id fromDirectory,
const char *fromName, vnode_id toDirectory,
const char *toName, vnode_id node);
extern status_t notify_stat_changed(mount_id device, vnode_id node,
uint32 statFields);
extern status_t notify_attribute_changed(mount_id device, vnode_id node,
const char *attribute, int32 cause);
extern status_t notify_query_entry_created(port_id port, int32 token,
mount_id device, vnode_id directory, const char *name,
vnode_id node);
extern status_t notify_query_entry_removed(port_id port, int32 token,
mount_id device, vnode_id directory, const char *name,
vnode_id node);
#ifdef __cplusplus
}
#endif
#endif /* _FS_INTERFACE_H */
+68
View File
@@ -0,0 +1,68 @@
#ifndef _ISA_CONFIG_H
#define _ISA_CONFIG_H
#include <config_manager.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef union {
uint32 id;
uchar b[4];
} EISA_PRODUCT_ID;
/* uint32 MAKE_EISA_PRODUCT_ID(EISA_PRODUCT_ID* ptr, char ch0, char ch1, char ch2, uint12 prod_num, uint4 rev) */
/* example: MAKE_EISA_PRODUCT_ID(&foo_id, 'F','O','O', 0xdb1, 3); */
/* makes correct little-endian format */
#define MAKE_EISA_PRODUCT_ID(ptr, ch0, ch1, ch2, prod_num, rev) \
do { \
(ptr)->b[0] = (uint8)(((((ch0) - 'A' + 1) & 0x1f) << 2) | ((((ch1) - 'A' + 1) & 0x18) >> 3)); \
(ptr)->b[1] = (uint8)(((((ch1) - 'A' + 1) & 0x07) << 5) | ((((ch2) - 'A' + 1) & 0x1f) )); \
(ptr)->b[2] = (uint8)((((prod_num) & 0xff0) >> 4)); \
(ptr)->b[3] = (uint8)((((prod_num) & 0x00f) << 4) | ((rev) & 0xf) ); \
} while(0)
/* Compare IDs without revision */
/* bool EQUAL_EISA_PRODUCT_ID(EISA_PRODUCT_ID id1, EISA_PRODUCT_ID id2); */
#define EQUAL_EISA_PRODUCT_ID(id1, id2) \
(((id1).b[0] == (id2).b[0]) && ((id1).b[1] == (id2).b[1]) && ((id1).b[2] == (id2).b[2]) && (((id1).b[3] & 0xf0) == ((id2).b[3] & 0xf0)))
#define B_MAX_COMPATIBLE_IDS 8
/* This structure is deprecated and will be going away in the next release */
struct isa_device_info {
struct device_info info;
uchar csn;
uchar ldn;
uint32 vendor_id;
uint32 card_id; /* a.k.a. serial number */
uint32 logical_device_id;
uint32 num_compatible_ids;
uint32 compatible_ids[B_MAX_COMPATIBLE_IDS];
char card_name[B_OS_NAME_LENGTH];
char logical_device_name[B_OS_NAME_LENGTH];
};
/* So use this instead */
struct isa_info {
uchar csn;
uchar ldn;
uint32 vendor_id;
uint32 card_id; /* a.k.a. serial number */
uint32 logical_device_id;
uint32 num_compatible_ids;
uint32 compatible_ids[B_MAX_COMPATIBLE_IDS];
char card_name[B_OS_NAME_LENGTH];
char logical_device_name[B_OS_NAME_LENGTH];
};
/* for the mem_descriptor cookie */
#define B_ISA_MEMORY_32_BIT 0x100
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,68 @@
/*
** Copyright 2002, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef LENDIAN_BITFIELD_H
#define LENDIAN_BITFIELD_H
#include <ByteOrder.h>
#define B_HOST_IS_LENDIAN 1
#if B_HOST_IS_BENDIAN
#define LBITFIELD8_2(b1,b2) uint8 b2,b1
#define LBITFIELD8_3(b1,b2,b3) uint8 b3,b2,b1
#define LBITFIELD8_4(b1,b2,b3,b4) uint8 b4,b3,b2,b1
#define LBITFIELD8_5(b1,b2,b3,b4,b5) uint8 b5,b4,b3,b2,b1
#define LBITFIELD8_6(b1,b2,b3,b4,b5,b6) uint8 b6,b5,b4,b3,b2,b1
#define LBITFIELD8_7(b1,b2,b3,b4,b5,b6,b7) uint8 b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD8_8(b1,b2,b3,b4,b5,b6,b7,b8) uint8 b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD2(b1,b2) uint16 b2,b1
#define LBITFIELD3(b1,b2,b3) uint16 b3,b2,b1
#define LBITFIELD4(b1,b2,b3,b4) uint16 b4,b3,b2,b1
#define LBITFIELD5(b1,b2,b3,b4,b5) uint16 b5,b4,b3,b2,b1
#define LBITFIELD6(b1,b2,b3,b4,b5,b6) uint16 b6,b5,b4,b3,b2,b1
#define LBITFIELD7(b1,b2,b3,b4,b5,b6,b7) uint16 b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD8(b1,b2,b3,b4,b5,b6,b7,b8) uint16 b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) uint16 b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD10(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10) uint16 b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD11(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11) uint16 b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD12(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12) uint16 b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD13(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13) uint16 b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD14(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14) uint16 b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD15(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15) uint16 b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#define LBITFIELD16(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16) uint16 b16,b15,b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1
#elif B_HOST_IS_LENDIAN
#define LBITFIELD8_2(b1,b2) uint8 b1,b2
#define LBITFIELD8_3(b1,b2,b3) uint8 b1,b2,b3
#define LBITFIELD8_4(b1,b2,b3,b4) uint8 b1,b2,b3,b4
#define LBITFIELD8_5(b1,b2,b3,b4,b5) uint8 b1,b2,b3,b4,b5
#define LBITFIELD8_6(b1,b2,b3,b4,b5,b6) uint8 b1,b2,b3,b4,b5,b6
#define LBITFIELD8_7(b1,b2,b3,b4,b5,b6,b7) uint8 b1,b2,b3,b4,b5,b6,b7
#define LBITFIELD8_8(b1,b2,b3,b4,b5,b6,b7,b8) uint8 b1,b2,b3,b4,b5,b6,b7,b8
#define LBITFIELD2(b1,b2) uint16 b1,b2
#define LBITFIELD3(b1,b2,b3) uint16 b1,b2,b3
#define LBITFIELD4(b1,b2,b3,b4) uint16 b1,b2,b3,b4
#define LBITFIELD5(b1,b2,b3,b4,b5) uint16 b1,b2,b3,b4,b5
#define LBITFIELD6(b1,b2,b3,b4,b5,b6) uint16 b1,b2,b3,b4,b5,b6
#define LBITFIELD7(b1,b2,b3,b4,b5,b6,b7) uint16 b1,b2,b3,b4,b5,b6,b7
#define LBITFIELD8(b1,b2,b3,b4,b5,b6,b7,b8) uint16 b1,b2,b3,b4,b5,b6,b7,b8
#define LBITFIELD9(b1,b2,b3,b4,b5,b6,b7,b8,b9) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9
#define LBITFIELD10(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10
#define LBITFIELD11(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11
#define LBITFIELD12(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12
#define LBITFIELD13(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
#define LBITFIELD14(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14
#define LBITFIELD15(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15
#define LBITFIELD16(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16) uint16 b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16
#else
#error "Unknown host endianness"
#endif
#endif /* LENDIAN_BITFIELD_H */
+70
View File
@@ -0,0 +1,70 @@
/*
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
/*
Paging-safe allocation of locked memory.
Library for managing temporary, locked memory with the condition of
not calling any function during allocation that can lead to paging.
Such memory is needed by drivers that are used to access the page file
but still need locked memory to execute requests.
Basically, a background thread manages a memory pool where blocks
are allocated from. If the pool is empty, allocation is delayed until
either a blocks is freed or the pool is enlarged by the background
thread.
All memory blocks must have same size and can be pre-initialized when
added to memory pool (and cleaned-up when removed from pool). The
free list is stored within free memory blocks, so you have to specify
a block offset where the manager can store the list pointers without
interfering with pre-initialization.
You can also specify an alignment, e.g. if the blocks are used for
DMA access, a minimum pool size (in blocks), a maximum pool size
(in blocks) and the size of memory chunks to be added if the entire
pool is allocated.
*/
#ifndef __LOCKED_POOL_H__
#define __LOCKED_POOL_H__
#include <device_manager.h>
typedef struct locked_pool *locked_pool_cookie;
typedef status_t (*locked_pool_add_hook)(void *block, void *arg);
typedef void (*locked_pool_remove_hook)(void *block, void *arg);
typedef struct {
module_info minfo;
// allocate block
void *(*alloc)(locked_pool_cookie pool);
// free block
void (*free)(locked_pool_cookie pool, void *block);
// create new pool
// block_size - size of one memory block
// alignment - set address bits here that must be zero for block addresses
// next_ofs - offset in block where internal next-pointer can be stored
// chunk_size - how much system memory is to be allocated at once
// max_blocks - maximum number of blocks
// min_free_block - minimum number of free blocks
// name - name of pool
// lock_flags - flags to be passed to lock_memory()
// alloc_hook - hook to be called when new block is added to pool (can be NULL )
// free_hook - hook to be called when block is removed from pool (can be NULL )
// hook_arg - value to be passed to hooks as arg
locked_pool_cookie (*create)(int block_size, int alignment, int next_ofs,
int chunk_size, int max_blocks, int min_free_blocks, const char *name,
uint32 lock_flags, locked_pool_add_hook add_hook,
locked_pool_remove_hook remove_hook, void *hook_arg);
void (*destroy)(locked_pool_cookie pool);
} locked_pool_interface;
#define LOCKED_POOL_MODULE_NAME "generic/locked_pool/v1"
#endif
+118
View File
@@ -0,0 +1,118 @@
/* ++++++++++
FILE: midi_driver.h
REVS: $Revision: 1.1 $
NAME: herold
DATE: Tue Jun 4 15:23:29 PDT 1996
Interface to /dev/midi, the midi driver
+++++ */
/*
Copyright 1999, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
*/
#ifndef _MIDI_DRIVER_H
#define _MIDI_DRIVER_H
#include <Drivers.h>
#include <module.h>
/* -----
ioctl codes
----- */
/* the old opcodes are deprecated, and may or may not work
in newer drivers */
enum {
B_MIDI_GET_READ_TIMEOUT = B_MIDI_DRIVER_BASE,
B_MIDI_SET_READ_TIMEOUT,
B_MIDI_TIMED_READ,
B_MIDI_TIMED_WRITE,
B_MIDI_WRITE_SYNC,
B_MIDI_WRITE_CLEAR,
B_MIDI_GET_READ_TIMEOUT_OLD = B_DEVICE_OP_CODES_END + 1,
B_MIDI_SET_READ_TIMEOUT_OLD
};
/* the default timeout when you open a midi driver */
#define B_MIDI_DEFAULT_TIMEOUT 1000000000000000LL
/* Usage:
To read, set "data" to a pointer to your buffer, and "size" to the
maximum size of this buffer. On return, "when" will contain the time
at which the data was received (first byte) and "size" will contain
the actual amount of data read.
Call ioctl(fd, B_MIDI_TIMED_READ, &midi_timed_data, sizeof(midi_timed_data));
To write, set "when" to when you want the first byte to go out the
wire, set "data" to point to your data, and set "size" to the size
of your data.
Call ioctl(fd, B_MIDI_TIMED_WRITE, &midi_timed_data, sizeof(midi_timed_data));
*/
typedef struct {
bigtime_t when;
size_t size;
unsigned char * data;
} midi_timed_data;
/* The MIDI parser returns the number of bytes that a message contains, given the */
/* initial byte. For some messages, this is not known until the second byte is seen. */
/* For such messages, a state > 0 is returned as well as some count > 0. When state */
/* is > 0, you should call (*parse) for the next byte as well, which might modify */
/* the returned message size. Message size will always be returned with the current */
/* byte being counted as byte 1. A return of 0 means that the byte initiates a new */
/* message. SysX is handled by returning max_size until the end or next initial message */
/* is seen. So your loop looks something like: */
/*
uint32 state = 0; // Only set this to 0 the first time you call the parser.
// preserve the 'state' between invocations of your read() hook.
int todo = 0;
unsigned char * end = in_buf+buf_size
unsigned char * out_buf = in_buf;
while (true) {
uchar byte = read_midi();
if (!todo || state) {
todo = (*parser->parse)(&state, byte, end-out_buf);
}
if (todo < 1) {
unput_midi(byte);
} else {
*(out_buf++) = byte;
todo--;
}
if (todo < 1 || out_buf >= end) {
received_midi_message(in_buf, out_buf-in_buf);
todo = 0;
}
}
*/
#define B_MIDI_PARSER_MODULE_NAME "media/midiparser/v1"
typedef struct _midi_parser_module_info {
module_info minfo;
int (*parse)(uint32 * state, uchar byte, size_t max_size);
int _reserved_;
} midi_parser_module_info;
#define B_MPU_401_MODULE_NAME "generic/mpu401/v1"
enum {
B_MPU_401_ENABLE_CARD_INT = 1,
B_MPU_401_DISABLE_CARD_INT
};
typedef struct _generic_mpu401_module {
module_info minfo;
status_t (*create_device)(int port, void ** out_storage, uint32 workarounds, void (*interrupt_op)(int32 op, void * card), void * card);
status_t (*delete_device)(void * storage);
status_t (*open_hook)(void * storage, uint32 flags, void ** out_cookie);
status_t (*close_hook)(void * cookie);
status_t (*free_hook)(void * cookie);
status_t (*control_hook)(void * cookie, uint32 op, void * data, size_t len);
status_t (*read_hook)(void * cookie, off_t pos, void * data, size_t * len);
status_t (*write_hook)(void * cookie, off_t pos, const void * data, size_t * len);
bool (*interrupt_hook)(void * cookie);
int _reserved_;
} generic_mpu401_module;
#endif
+56
View File
@@ -0,0 +1,56 @@
/*******************************************************************************
/
/ File: mime_table.h
/
/ Description: Kernel mime table and matcher module API
/
/ Copyright 2005, François Revol.
/
*******************************************************************************/
#ifndef _MIME_TABLE_MODULE_H_
#define _MIME_TABLE_MODULE_H_
#include <module.h>
struct ext_mime {
char *extension;
char *mime;
};
#ifdef __cplusplus
extern "C" {
#endif
/*
status_t get_table(struct ext_mime **table)
Returns the current kernel mime table.
You must call free_table() when finished with it.
void free_table(struct ext_mime *table)
Frees the given mime table;
const char * mime_for_ext(const char *ext)
Returns the known mime type for the given extension.
const char * ext_for_mime(const char *mime)
Returns the known extension for the given mime type.
*/
#define B_MIME_TABLE_MODULE_NAME "generic/mime_table/v1"
typedef struct {
module_info minfo;
status_t (*get_table)(struct ext_mime **table);
void (*free_table)(struct ext_mime *table);
const char * (*mime_for_ext)(const char *ext);
const char * (*ext_for_mime)(const char *mime);
} mime_table_module_info;
#ifdef __cplusplus
}
#endif
#endif
+58
View File
@@ -0,0 +1,58 @@
/* Modules Definitions
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _MODULE_H
#define _MODULE_H
#include <OS.h>
/* Every module exports a list of module_info structures.
* It defines the interface of the module and the name
* that is used to access the interface.
*/
typedef struct module_info {
const char *name;
uint32 flags;
status_t (*std_ops)(int32, ...);
} module_info;
/* module standard operations */
#define B_MODULE_INIT 1
#define B_MODULE_UNINIT 2
/* module flags */
#define B_KEEP_LOADED 0x00000001
/* Use the module_dependency structure to let the
* kernel automatically load modules yet depend on
* before B_MODULE_INIT is called.
*/
typedef struct module_dependency {
const char *name;
module_info **info;
} module_dependency;
#ifdef __cplusplus
extern "C" {
#endif
extern status_t get_module(const char *path, module_info **_info);
extern status_t put_module(const char *path);
extern status_t get_next_loaded_module_name(uint32 *cookie, char *buffer, size_t *_bufferSize);
extern void *open_module_list(const char *prefix);
extern status_t close_module_list(void *cookie);
extern status_t read_next_module_name(void *cookie, char *buffer, size_t *_bufferSize);
#ifdef __cplusplus
}
#endif
#endif /* _MODULE_H */
+22
View File
@@ -0,0 +1,22 @@
/* Node monitor calls for kernel add-ons
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _DRIVERS_NODE_MONITOR_H
#define _DRIVERS_NODE_MONITOR_H
#include <OS.h>
#include <storage/NodeMonitor.h>
extern status_t stop_notifying(port_id port, uint32 token);
extern status_t start_watching(dev_t device, ino_t node, uint32 flags,
port_id port, uint32 token);
extern status_t stop_watching(dev_t device, ino_t node, uint32 flags,
port_id port, uint32 token);
// ToDo: add simple message parsing convenience functionality
#endif /* _DRIVERS_NODE_MONITOR_H */
+55
View File
@@ -0,0 +1,55 @@
/*
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
PnP devfs driver interface.
The interface follows the normal pnp driver rules, i.e.
your driver creates a node for it and chooses PNP_DEVFS_MODULE_NAME
as the consumer, the type must be PNP_DEVFS_TYPE_NAME. The file
name is set via a PNP_DEVFS_FILENAME item.
Loading and unloading of your driver is done via the pnp manager.
Hooks are similar to the original devfs interface, but the open
hook gets the driver cookie (as returned by init_device of the
driver) instead of a filename.
*/
#ifndef _PNP_DEVFS_H
#define _PNP_DEVFS_H
#include <Drivers.h>
#include <device_manager.h>
// changed open hook - gets cookie returned by init_device instead of name
typedef status_t (*pnp_device_open_hook)(void *device_cookie, uint32 flags,
void **handle_cookie);
// new interface to devfs
typedef struct pnp_devfs_driver_info {
driver_module_info info;
pnp_device_open_hook open; // called to open the device
device_close_hook close; // called to close the device
device_free_hook free; // called to free the cookie
device_control_hook control; // called to control the device
device_read_hook read; // reads from the device
device_write_hook write; // writes to the device
device_select_hook select; // start select (can be NULL)
device_deselect_hook deselect; // stop select (can be NULL)
device_read_pages_hook read_pages; // scatter-gather read from the device (can be NULL)
device_write_pages_hook write_pages; // scatter-gather write to the device (can be NULL)
} pnp_devfs_driver_info;
// items:
// name under which the device should be published under /dev (required, string)
#define PNP_DEVFS_FILENAME "devfs/filename"
#define PNP_DEVFS_MODULE_NAME "system/devfs/device_v1"
#endif
+144
View File
@@ -0,0 +1,144 @@
#ifndef USB_AUDIO_H
#define USB_AUDIO_H
// (Partial) USB Class Definitions for Audio Devices, version 1.0
// Reference: http://www.usb.org/developers/devclass_docs/audio10.pdf
#include <BeBuild.h> // for _PACKED definition
#define USB_AUDIO_DEVICE_CLASS 0x01
#define USB_AUDIO_CLASS_VERSION 0x0100
enum {
USB_AUDIO_INTERFACE_AUDIO_CLASS = 0x01
};
enum { // Audio Interface Subclasses
USB_AUDIO_INTERFACE_AUDIOCONTROL_SUBCLASS = 0x01, //
USB_AUDIO_INTERFACE_AUDIOSTREAMING_SUBCLASS, //
USB_AUDIO_INTERFACE_MIDISTREAMING_SUBCLASS //
};
enum { // Audio Class-Specific AudioControl Interface descriptor subtypes
USB_AUDIO_AC_HEADER = 0x01,
USB_AUDIO_AC_INPUT_TERMINAL,
USB_AUDIO_AC_OUTPUT_TERMINAL,
USB_AUDIO_AC_MIXER_UNIT,
USB_AUDIO_AC_SELECTOR_UNIT,
USB_AUDIO_AC_FEATURE_UNIT,
USB_AUDIO_AC_PROCESSING_UNIT,
USB_AUDIO_AC_EXTENSION_UNIT
};
enum { // Audio Class-Specific AudioStreaming Interface descriptor subtypes
USB_AUDIO_AS_GENERAL = 0x01,
USB_AUDIO_AS_FORMAT_TYPE,
USB_AUDIO_AS_FORMAT_SPECIFIC
};
enum { // Processing Unit Process Types (for USB_AUDIO_AC_PROCESSING_UNIT)
USB_AUDIO_UPDOWNMIX_PROCESS = 0x01,
USB_AUDIO_DOLBY_PROLOGIC_PROCESS,
USB_AUDIO_3D_STEREO_EXTENDER_PROCESS,
USB_AUDIO_REVERBERATION_PROCESS,
USB_AUDIO_CHORUS_PROCESS,
USB_AUDIO_DYN_RANGE_COMP_PROCESS
};
// AudioControl request codes
#define USB_AUDIO_SET_CURRENT 0x01
#define USB_AUDIO_GET_CURRENT 0x81
#define USB_AUDIO_SET_MIN 0x02
#define USB_AUDIO_GET_MIN 0x82
#define USB_AUDIO_SET_MAX 0x03
#define USB_AUDIO_GET_MAX 0x83
#define USB_AUDIO_SET_RES 0x04
#define USB_AUDIO_GET_RES 0x84
#define USB_AUDIO_SET_MEM 0x05
#define USB_AUDIO_GET_MEM 0x85
#define USB_AUDIO_GET_STATUS 0xFF
enum { // Terminal Control Selectors
USB_AUDIO_COPY_PROTECT_CONTROL = 0x01
};
/* A.10.2 Feature Unit Control Selectors */
#define AC_FU_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_MUTE_CONTROL 0x01
#define USB_AUDIO_VOLUME_CONTROL 0x02
#define USB_AUDIO_BASS_CONTROL 0x03
#define USB_AUDIO_MID_CONTROL 0x04
#define USB_AUDIO_TREBLE_CONTROL 0x05
#define USB_AUDIO_GRAPHIC_EQUALIZER_CONTROL 0x06
#define USB_AUDIO_AUTOMATIC_GAIN_CONTROL 0x07
#define USB_AUDIO_DELAY_CONTROL 0x08
#define USB_AUDIO_BASS_BOOST_CONTROL 0x09
#define USB_AUDIO_LOUDNESS_CONTROL 0x0A
/* A.10.3.1 Up/Down-mix Processing Unit Control Selectors */
#define USB_AUDIO_UD_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_UD_ENABLED_CONTROL 0x01
#define USB_AUDIO_UD_MODE_SELECT_CONTROL 0x02
/* A.10.3.2 Dolby Prologic(tm) Processing Unit Control Selectors */
#define USB_AUDIO_DP_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_DP_ENABLE_CONTROL 0x01
#define USB_AUDIO_DP_MODE_SELECT_CONTROL 0x02
/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
#define USB_AUDIO_3D_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_3D_ENABLED_CONTROL 0x01
#define USB_AUDIO_3D_SPACIOUSNESS_CONTROL 0x03
/* A.10.3.4 Reverberation Processing Unit Control Selectors */
#define USB_AUDIO_RV_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_RV_ENABLE_CONTROL 0x01
#define USB_AUDIO_RV_REVERB_LEVEL_CONTROL 0x02
#define USB_AUDIO_RV_REVERB_TIME_CONTROL 0x03
#define USB_AUDIO_RV_REVERB_FEEDBACK_CONTROL 0x04
/* A.10.3.5 Chorus Processing Unit Control Selectors */
#define USB_AUDIO_CH_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_CH_ENABLE_CONTROL 0x01
#define USB_AUDIO_CHORUS_LEVEL_CONTROL 0x02
#define USB_AUDIO_CHORUS_RATE_CONTROL 0x03
#define USB_AUDIO_CHORUS_DETH_CONTROL 0x04
/* A.10.3.6 Dynamic Range Compressor Processing Unit Control Selectors */
#define USB_AUDIO_DR_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_DR_ENABLE_CONTROL 0x01
#define USB_AUDIO_COMPRESSION_RATE_CONTROL 0x02
#define USB_AUDIO_MAXAMPL_CONTROL 0x03
#define USB_AUDIO_THRESHOLD_CONTROL 0x04
#define USB_AUDIO_ATTACK_TIME 0x05
#define USB_AUDIO_RELEASE_TIME 0x06
/* A.10.4 Extension Unit Control Selectors */
#define USB_AUDIO_XU_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_XU_ENABLE_CONTROL 0x01
/* A.10.5 Endpoint Control Selectors */
#define USB_AUDIO_EP_CONTROL_UNDEFINED 0x00
#define USB_AUDIO_SAMPLING_FREQ_CONTROL 0x01
#define USB_AUDIO_PITCH_CONTROL 0x02
typedef struct {
uint8 length;
uint8 type;
uint8 subtype;
uint8 format_type;
uint8 num_channels;
uint8 subframe_size;
uint8 bit_resolution;
uint8 sample_freq_type;
uint8 sample_freq[3]; // [0] + [1] << 8 + [2] << 16
// if sample_freq_type != 1,
// (sample_freq_type - 1) x uint8 sample_freq[3] follows...
} _PACKED usb_audio_format_type_descriptor;
#define USB_AUDIO_FORMAT_TYPE_UNDEFINED 0x00
#define USB_AUDIO_FORMAT_TYPE_I 0x01
#define USB_AUDIO_FORMAT_TYPE_II 0x02
#define USB_AUDIO_FORMAT_TYPE_III 0x03
#endif // USB_AUDIO_H
+136
View File
@@ -0,0 +1,136 @@
#ifndef USB_CDC_H
#define USB_CDC_H
// (Partial) USB Class Definitions for Communication Devices (CDC), version 1.1
// Reference: http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
#define USB_COMMUNICATION_DEVICE_CLASS 0x02
#define USB_CDC_COMMUNICATION_INTERFACE_CLASS 0x02
#define USB_CDC_CLASS_VERSION 0x0101
enum { // Communication Interface Subclasses
USB_CDC_COMMUNICATION_INTERFACE_DLCM_SUBCLASS = 0x01, // Direct Line Control Model
USB_CDC_COMMUNICATION_INTERFACE_ACM_SUBCLASS, // Abstract Control Model
USB_CDC_COMMUNICATION_INTERFACE_TCM_SUBCLASS, // Telephone Control Model
USB_CDC_COMMUNICATION_INTERFACE_MCCM_SUBCLASS, // Multi-Channel Control Model
USB_CDC_COMMUNICATION_INTERFACE_CAPICM_SUBCLASS, // CAPI Control Model
USB_CDC_COMMUNICATION_INTERFACE_ENCM_SUBCLASS, // Ethernet Networking Control Model
USB_CDC_COMMUNICATION_INTERFACE_ATMNCM_SUBCLASS // ATM Networking Control Model
};
enum { // Communication Interface Class Control Protocols
USB_CDC_COMMUNICATION_INTERFACE_NONE_PROTOCOL = 0x00, // No class specific protocol required
USB_CDC_COMMUNICATION_INTERFACE_V25TER_PROTOCOL = 0x01, // Common AT commands (also knowns as "Hayes compatible")
USB_CDC_COMMUNICATION_INTERFACE_SPECIFIC_PROTOCOL = 0xff // Vendor-specific protocol
};
#define USB_CDC_DATA_INTERFACE_CLASS 0x0a
enum { // Management Element Requests (p62)
USB_CDC_SEND_ENCAPSULATED_COMMAND = 0x00,
USB_CDC_GET_ENCAPSULATED_RESPONSE,
USB_CDC_SET_COMM_FEATURE,
USB_CDC_GET_COMM_FEATURE,
USB_CDC_CLEAR_COMM_FEATURE,
// 0x05 -> 0x0F: reserved for future use
USB_CDC_SET_AUX_LINE_STATE = 0x10,
USB_CDC_SET_HOOK_STATE,
USB_CDC_PULSE_SETUP,
USB_CDC_SEND_PULSE,
USB_CDC_SET_PULSE_TIME,
USB_CDC_RING_AUX_JACK,
// 0x16 -> 0x1F: reserved for future use
USB_CDC_SET_LINE_CODING = 0x20,
USB_CDC_GET_LINE_CODING,
USB_CDC_SET_CONTROL_LINE_STATE,
USB_CDC_SEND_BREAK,
// 0x24 -> 0x2F: reserved for future use
USB_CDC_SET_RINGER_PARMS = 0x30,
USB_CDC_GET_RINGER_PARMS,
USB_CDC_SET_OPERATION_PARMS,
USB_CDC_GET_OPERATION_PARMS,
USB_CDC_SET_LINE_PARMS,
USB_CDC_GET_LINE_PARMS,
USB_CDC_DIAL_DIGITS,
USB_CDC_SET_UNIT_PARAMETER,
USB_CDC_GET_UNIT_PARAMETER,
USB_CDC_CLEAR_UNIT_PARAMETER,
USB_CDC_GET_PROFILE,
// 0x3B -> 0x3F: reserved for future use
USB_CDC_SET_ETHERNET_MULTICAST_FILTERS = 0x40,
USB_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER,
USB_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER,
USB_CDC_SET_ETHERNET_PACKET_FILTER,
USB_CDC_GET_ETHERNET_STATISTIC,
// 0x45 -> 0x4F: reserved for future use
USB_CDC_SET_ATM_DATA_FORMAT = 0x50,
USB_CDC_GET_ATM_DEVICE_STATISTICS,
USB_CDC_SET_ATM_DEFAULT_VC,
USB_CDC_GET_ATM_VC_STATISTICS
// 0x54 -> 0xFF: reserved for future use
};
enum { // Feature Selector (for USB_CDC_SET/GET/CLEAR_COMM_FEATURE (p65-66))
USB_CDC_ABSTRACT_STATE = 0x01,
USB_CDC_COUNTRY_SETTING = 0x02
};
enum { // ABSTRACT_STATE bitmap (for USB_CDC_ABSTRAT_STATE Feature Selector (p66))
USB_CDC_ABSTRACT_STATE_IDLE = 0x01,
USB_CDC_ABSTRACT_STATE_DATA_MULTIPLEXED = 0x02
};
typedef struct { // Line Coding Structure (for USB_CDC_SET/GET_LINE_CODING (p69))
uint32 speed;
uint8 stopbits;
uint8 parity;
uint8 databits;
} _PACKED usb_cdc_line_coding;
enum { // CDC stopbits values (for Line Coding Structure stopbits field)
USB_CDC_1_STOPBIT = 0,
USB_CDC_1_5_STOPBITS,
USB_CDC_2_STOPBITS
};
enum { // CDC parity values (for Line Coding Structure parity field)
USB_CDC_NO_PARITY = 0,
USB_CDC_ODD_PARITY,
USB_CDC_EVEN_PARITY,
USB_CDC_MARK_PARITY,
USB_CDC_SPACE_PARITY
};
enum { // CDC Control Signal bitmap (for CDC_SET_CONTROL_LINE_STATE request)
USB_CDC_CONTROL_SIGNAL_STATE_DTR = 0x01,
USB_CDC_CONTROL_SIGNAL_STATE_RTS = 0x02
};
enum { // Notification Elements notifications (p84)
USB_CDC_NETWORK_CONNECTION = 0x00,
USB_CDC_RESPONSE_AVAILABLE,
// 0x02 -> 0x07: reserved for future use
USB_CDC_AUX_JACK_HOOK_STATE = 0x08,
USB_CDC_RING_DETECT,
// 0x0a -> 0x1f: reserved for future use
USB_CDC_SERIAL_STATE = 0x20,
// 0x21 -> 0x27: reserved for future use
USB_CDC_CALL_STATE_CHANGE = 0x28,
USB_CDC_LINE_STATE_CHANGE,
USB_CDC_CONNECTION_SPEED_CHANGE
// 0x2b -> 0xff: reserved for future use
};
enum { // CDC UART State bitmap (for USB_CDC_SERIAL_STATE notification)
USB_CDC_UART_STATE_DCD = 0x01,
USB_CDC_UART_STATE_DSR = 0x02,
USB_CDC_UART_STATE_BREAK = 0x04,
USB_CDC_UART_STATE_RING = 0x08,
USB_CDC_UART_STATE_FRAMING_ERROR = 0x10,
USB_CDC_UART_STATE_PARITY_ERROR = 0x20,
USB_CDC_UART_STATE_OVERRUN_ERROR = 0x40
};
#endif // USB_CDC_H
+116
View File
@@ -0,0 +1,116 @@
#ifndef USB_HID_H
#define USB_HID_H
// (Partial) USB Class Definitions for HID Devices, version 1.11
// Reference: http://www.usb.org/developers/devclass_docs/hid1_11.pdf
#define USB_HID_DEVICE_CLASS 0x03
#define USB_HID_CLASS_VERSION 0x0100
enum { // HID Interface Subclasses
USB_HID_INTERFACE_NO_SUBCLASS = 0x00, // No Subclass
USB_HID_INTERFACE_BOOT_SUBCLASS // Boot Interface Subclass
};
enum { // HID Class-Specific descriptor subtypes
USB_HID_DESCRIPTOR_HID = 0x21,
USB_HID_DESCRIPTOR_REPORT,
USB_HID_DESCRIPTOR_PHYSICAL
};
enum { // HID Class-specific requests
USB_REQUEST_HID_GET_REPORT = 0x01,
USB_REQUEST_HID_GET_IDLE,
USB_REQUEST_HID_GET_PROTOCOL,
USB_REQUEST_HID_SET_REPORT = 0x09,
USB_REQUEST_HID_SET_IDLE,
USB_REQUEST_HID_SET_PROTOCOL
};
typedef struct
{
uint8 length;
uint8 descriptor_type;
uint16 hid_version;
uint8 country_code;
uint8 num_descriptors;
struct
{
uint8 descriptor_type;
uint16 descriptor_length;
} _PACKED descriptor_info [1];
} _PACKED usb_hid_descriptor;
/*
Usage Pages/IDs
*/
enum
{
USAGE_PAGE_GENERIC_DESKTOP = 0x1,
USAGE_PAGE_SIMULATION,
USAGE_PAGE_VR,
USAGE_PAGE_SPORT,
USAGE_PAGE_GAME,
USAGE_PAGE_GENERIC,
USAGE_PAGE_KEYBOARD,
USAGE_PAGE_LED,
USAGE_PAGE_BUTTON,
USAGE_PAGE_ORDINAL,
USAGE_PAGE_TELEPHONY,
USAGE_PAGE_CONSUMER,
USAGE_PAGE_DIGITIZER,
USAGE_PAGE_PID = 0xf,
USAGE_PAGE_UNICODE,
USAGE_PAGE_ALPHANUM_DISPLAY = 0x14,
USAGE_PAGE_MEDICAL = 0x40
};
/* Page 1: Generic Desktop */
enum
{
USAGE_ID_POINTER = 0x1,
USAGE_ID_MOUSE,
USAGE_ID_JOYSTICK = 0x4,
USAGE_ID_GAMEPAD,
USAGE_ID_KEYBOARD,
USAGE_ID_KEYPAD,
USAGE_ID_MULTIAXIS = 0x8,
USAGE_ID_X = 0x30,
USAGE_ID_Y,
USAGE_ID_Z,
USAGE_ID_RX,
USAGE_ID_RY,
USAGE_ID_RZ,
USAGE_ID_SLIDER,
USAGE_ID_DIAL,
USAGE_ID_WHEEL,
USAGE_ID_HAT_SWITCH,
USAGE_ID_COUNTED_BUFFER,
USAGE_ID_BYTE_COUNT,
USAGE_ID_MOTION_WAKEUP,
USAGE_ID_START,
USAGE_ID_SELECT,
USAGE_ID_VX = 0x40,
USAGE_ID_VY,
USAGE_ID_VZ,
USAGE_ID_VBRX,
USAGE_ID_VBRY,
USAGE_ID_VBRZ,
USAGE_ID_VNO,
USAGE_ID_FEATURE_NOTIFICATION
};
/* Page 2: Simulation */
enum
{
USAGE_ID_RUDDER = 0xBA,
USAGE_ID_THROTTLE = 0xBB,
};
#endif // USB_HID_H
+173
View File
@@ -0,0 +1,173 @@
#ifndef USB_LANGIDS_H
#define USB_LANGIDS_H
// USB Language Identifiers, 3/29/2000, version 1.0
// Reference: http://www.usb.org/developers/docs/USB_LANGIDs.pdf
#define USB_LANGIDS_VERSION 0x0100 // version 1.0
// descriptor string index 0 = supported LANGIDs array
#define USB_LANGIDS_STRING_INDEX (0)
#define USB_PRIMARY_LANGID_MASK (0x003F) // 9 to 0 bits
#define USB_SUB_LANGID_MASK (0xFC00) // 15 to 10 bits
#define USB_PRIMARY_LANGID(id) (id & USB_PRIMARY_LANGID_MASK)
#define USB_SUB_LANGID(id) ((id & USB_SUB_LANGID_MASK) >> 10)
enum {
USB_LANGID_AFRIKAANS = 0x0436, // Afrikaans
USB_LANGID_ALBANIAN = 0x041c, // Albanian
USB_LANGID_ARABIC_SAUDI_ARABIA = 0x0401, // Arabic (Saudi Arabia)
USB_LANGID_ARABIC_IRAK = 0x0801, // Arabic (Irak)
USB_LANGID_ARABIC_EGYPT = 0x0c01, // Arabic (Egypt)
USB_LANGID_ARABIC_LYBYA = 0x1001, // Arabic (Libya)
USB_LANGID_ARABIC_ALGERIA = 0x1401, // Arabic (Algeria)
USB_LANGID_ARABIC_MOROCCO = 0x1801, // Arabic (Morocco)
USB_LANGID_ARABIC_TUNISIA = 0x1c01, // Arabic (Tunisia)
USB_LANGID_ARABIC_OMAN = 0x2001, // Arabic (Oman)
USB_LANGID_ARABIC_YEMEN = 0x2401, // Arabic (Yemen)
USB_LANGID_ARABIC_SYRIA = 0x2801, // Arabic (Syria)
USB_LANGID_ARABIC_JORDAN = 0x2c01, // Arabic (Jordan)
USB_LANGID_ARABIC_LEBANON = 0x3001, // Arabic (Lebanon)
USB_LANGID_ARABIC_KUWAIT = 0x3401, // Arabic (Kuwait)
USB_LANGID_ARABIC_UAE = 0x3801, // Arabic (U.A.E.)
USB_LANGID_ARABIC_BAHRAIN = 0x3c01, // Arabic (Bahrain)
USB_LANGID_ARABIC_QATAR = 0x4001, // Arabic (Qatar)
USB_LANGID_ARMENIAN = 0x042b, // Armenian
USB_LANGID_ASSAMESE = 0x044d, // Assamese
USB_LANGID_AZERI_LATIN = 0x042c, // Azeri (Latin)
USB_LANGID_AZERI_CYRILLIC = 0x082c, // Azeri (Cyrillic)
USB_LANGID_BASQUE = 0x042d, // Basque
USB_LANGID_BELARUSSIAN = 0x0423, // Belarussian
USB_LANGID_BENGALI = 0x0445, // Bengali
USB_LANGID_BULGARIAN = 0x0402, // Bulgarian
USB_LANGID_BURMESE = 0x0455, // Burmese
USB_LANGID_CATALAN = 0x0403, // Catalan
USB_LANGID_CHINESE_TAIWAN = 0x0404, // Chinese (Taiwan)
USB_LANGID_CHINESE_PRC = 0x0804, // Chinese (PRC = People Republic of Chinese)
USB_LANGID_CHINESE_HONG_KONG = 0x0c04, // Chinese (Hong Kong)
USB_LANGID_CHINESE_SINGAPORE = 0x1004, // Chinese (Singapore)
USB_LANGID_CHINESE_MACAU_SAR = 0x1404, // Chinese (Macau SAR)
USB_LANGID_CROATIAN = 0x041a, // Croatian
USB_LANGID_CZECH = 0x0405, // Czech
USB_LANGID_DANISH = 0x0406, // Danish
USB_LANGID_DUTCH_NETHERLANDS = 0x0413, // Dutch (Netherlands)
USB_LANGID_DUTCH_BELGIUM = 0x0813, // Dutch (Belgium)
USB_LANGID_ENGLISH_UNITED_STATES = 0x0409, // English (United States)
USB_LANGID_ENGLISH_UNITED_KINGDOM = 0x0809, // English (United Kingdom)
USB_LANGID_ENGLISH_AUSTRALIAN = 0x0c09, // English (Australian)
USB_LANGID_ENGLISH_CANADIAN = 0x1009, // English (Canadian)
USB_LANGID_ENGLISH_NEW_ZEALAND = 0x1409, // English (New Zealand)
USB_LANGID_ENGLISH_IRELAND = 0x1809, // English (Ireland)
USB_LANGID_ENGLISH_SOUTH_AFRICA = 0x1c09, // English (South Africa)
USB_LANGID_ENGLISH_JAMAICA = 0x2009, // English (Jamaica)
USB_LANGID_ENGLISH_CARIBBEAN = 0x2409, // English (Caribbean)
USB_LANGID_ENGLISH_BELIZE = 0x2809, // English (Belize)
USB_LANGID_ENGLISH_TRINIDAD = 0x2c09, // English (Trinidad)
USB_LANGID_ENGLISH_ZIMBABWE = 0x3009, // English (Zimbabwe)
USB_LANGID_ENGLISH_PHLIPPINES = 0x3409, // English (Philippines)
USB_LANGID_ESTONIAN = 0x0425, // Estonian
USB_LANGID_FAEROESE = 0x0438, // Faeroese
USB_LANGID_FARSI = 0x0429, // Farsi
USB_LANGID_FINNISH = 0x040b, // Finnish
USB_LANGID_FRENCH_STANDARD = 0x040c, // French (Standard)
USB_LANGID_FRENCH_BELGIAN = 0x080c, // French (Belgian)
USB_LANGID_FRENCH_CANADIAN = 0x0c0c, // French (Canadian)
USB_LANGID_FRENCH_SWITZERLAND = 0x100c, // French (Switzerland)
USB_LANGID_FRENCH_LUXEMBOURG = 0x140c, // French (Luxembourg)
USB_LANGID_FRENCH_MONACO = 0x180c, // French (Monaco)
USB_LANGID_GEORGIAN = 0x0437, // Georgian
USB_LANGID_GERMAN_STANDARD = 0x0407, // German (Standard)
USB_LANGID_GERMAN_SWITZERLAND = 0x0807, // German (Switzerland)
USB_LANGID_GERMAN_AUSTRIA = 0x0c07, // German (Austria)
USB_LANGID_GERMAN_LUXEMBOURG = 0x1007, // German (Luxembourg)
USB_LANGID_GERMAN_LIECHTENSTEIN = 0x1407, // German (Liechtenstein)
USB_LANGID_GREEK = 0x0408, // Greek
USB_LANGID_GUJARATI = 0x0447, // Gujarati
USB_LANGID_HEBREW = 0x040d, // Hebrew
USB_LANGID_HINDI = 0x0439, // Hindi
USB_LANGID_HUNGARIAN = 0x040e, // Hungarian
USB_LANGID_ICELANDIC = 0x040f, // Icelandic
USB_LANGID_INDONESIAN = 0x0421, // Indonesian
USB_LANGID_ITALIAN_STANDARD = 0x0410, // Italian (Standard)
USB_LANGID_ITALIAN_SWITZERLAND = 0x0810, // Italian (Switzerland)
USB_LANGID_JAPANESE = 0x0411, // Japanese
USB_LANGID_KANNADA = 0x044b, // Kannada
USB_LANGID_KASHMIRI_INDIA = 0x0860, // Kashmiri (India)
USB_LANGID_KAZAKH = 0x043f, // Kazakh
USB_LANGID_KONKANI = 0x0457, // Konkani
USB_LANGID_KOREAN_JOHAB = 0x0412, // Korean (Johab)
USB_LANGID_LATVIAN = 0x0426, // Latvian
USB_LANGID_LITHUANIAN = 0x0427, // Lithuanian
USB_LANGID_LITHUANIAN_CLASSIC = 0x0827, // Lithuanian (Classic)
USB_LANGID_MACEDONIAN = 0x042f, // Macedonian
USB_LANGID_MALAY_MALAYSIAN = 0x043e, // Malay (Malaysian)
USB_LANGID_MALAY_BRUNEI_DARUSSALAM = 0x083e, // Malay (Brunei Darussalam)
USB_LANGID_MALAYALAM = 0x044c, // Malayalam
USB_LANGID_MANIPURI = 0x0458, // Manipuri
USB_LANGID_MARATHI = 0x044e, // Marathi
USB_LANGID_NEPALI_INDIA = 0x0861, // Nepali (India)
USB_LANGID_NORWEGIAN_BOKMAL = 0x0414, // Norwegian (Bokmal)
USB_LANGID_NORWEGIAN_NYNORSK = 0x0814, // Norwegian (Nynorsk)
USB_LANGID_ORIYA = 0x0448, // Oriya
USB_LANGID_POLISH = 0x0415, // Polish
USB_LANGID_PORTUGUESE_BRAZIL = 0x0416, // Portuguese (Brazil)
USB_LANGID_PORTUGUESE_STANDARD = 0x0816, // Portuguese (Standard)
USB_LANGID_PUNJABI = 0x0446, // Punjabi
USB_LANGID_ROMANIAN = 0x0418, // Romanian
USB_LANGID_RUSSIAN = 0x0419, // Russian
USB_LANGID_SANSKRIT = 0x044f, // Sanskrit
USB_LANGID_SERBIAN_CYRILLIC = 0x0c1a, // Serbian (Cyrillic)
USB_LANGID_SERBIAN_LATIN = 0x081a, // Serbian (Latin)
USB_LANGID_SINDHI = 0x0459, // Sindhi
USB_LANGID_SLOVAK = 0x041b, // Slovak
USB_LANGID_SLOVENIAN = 0x0424, // Slovenian
USB_LANGID_SPANNISH_TRADITIONAL_SORT= 0x040a, // Spannish (Traditional Sort)
USB_LANGID_SPANNISH_MEXICAN = 0x080a, // Spannish (Mexican)
USB_LANGID_SPANNISH_MODERN_SORT = 0x0c0a, // Spannish (Modern Sort)
USB_LANGID_SPANNISH_GUATEMALA = 0x100a, // Spannish (Guatemala)
USB_LANGID_SPANNISH_COSTA_RICA = 0x140a, // Spannish (Costa Rica)
USB_LANGID_SPANNISH_PANAMA = 0x180a, // Spannish (Panama)
USB_LANGID_SPANNISH_DOMINICAN_REPUBLIC = 0x1c0a, // Spannish (Dominican Republic)
USB_LANGID_SPANNISH_VENEZUELA = 0x200a, // Spannish (Venezuela)
USB_LANGID_SPANNISH_COLOMBIA = 0x240a, // Spannish (Colombia)
USB_LANGID_SPANNISH_PERU = 0x280a, // Spannish (Peru)
USB_LANGID_SPANNISH_ARGENTINA = 0x2c0a, // Spannish (Argentina)
USB_LANGID_SPANNISH_ECUADOR = 0x300a, // Spannish (Ecuador)
USB_LANGID_SPANNISH_CHILE = 0x340a, // Spannish (Chile)
USB_LANGID_SPANNISH_URUGUAY = 0x380a, // Spannish (Uruguay)
USB_LANGID_SPANNISH_PARAGUAY = 0x3c0a, // Spannish (Paraguay)
USB_LANGID_SPANNISH_BOLIVIA = 0x400a, // Spannish (Bolivia)
USB_LANGID_SPANNISH_EL_SALVADOR = 0x440a, // Spannish (El Salvador)
USB_LANGID_SPANNISH_HONDURAS = 0x480a, // Spannish (Honduras)
USB_LANGID_SPANNISH_NICARAGUA = 0x4c0a, // Spannish (Nicaragua)
USB_LANGID_SPANNISH_PUERTO_RICO = 0x500a, // Spannish (Puerto Rico)
USB_LANGID_SUTU = 0x0430, // Sutu
USB_LANGID_SWAHILI_KENYA = 0x0441, // Swahili (Kenya)
USB_LANGID_SWEDISH = 0x041d, // Swedish
USB_LANGID_SWEDISH_FINLAND = 0x081d, // Swedish (Finland)
USB_LANGID_TAMIL = 0x0449, // Tamil
USB_LANGID_TATAR_TATARSTAN = 0x0444, // Tatar (Tatarstan)
USB_LANGID_TELUGU = 0x044a, // Telugu
USB_LANGID_THAI = 0x041e, // Thai
USB_LANGID_TURKISH = 0x041f, // Turkish
USB_LANGID_UKRAINIAN = 0x0422, // Ukrainian
USB_LANGID_URDU_PAKISTAN = 0x0420, // Urdu (Pakistan)
USB_LANGID_URDU_INDIA = 0x0820, // Urdu (India)
USB_LANGID_UZBEK_LATIN = 0x0443, // Uzbek (Latin)
USB_LANGID_UZBEK_CYRILLIC = 0x0843, // Uzbek (Cyrillic)
USB_LANGID_VIETNAMESE = 0x042a, // Vietnamese
USB_LANGID_HID_UDD = 0x04ff, // HID (Usage Data Descriptor)
USB_LANGID_HID1 = 0xf0ff, // HID (Vendor Defined 1)
USB_LANGID_HID2 = 0xf4ff, // HID (Vendor Defined 2)
USB_LANGID_HID3 = 0xf8ff, // HID (Vendor Defined 3)
USB_LANGID_HID4 = 0xfcff, // HID (Vendor Defined 4)
USB_LANGID_INVALID = 0x0000 // Invalid LANG ID
};
#endif // USB_LANGIDS_H
+20
View File
@@ -0,0 +1,20 @@
#ifndef USB_MIDI_H
#define USB_MIDI_H
#include "USB_audio.h"
// (Partial) USB Class Definitions for MIDI Devices, version 1.0
// Reference: http://www.usb.org/developers/devclass_docs/midi10.pdf
#define USB_MIDI_CLASS_VERSION 0x0100 // Class specification version 1.0
// USB MIDI Event Packet
// ... as clean structure:
typedef struct { // USB MIDI Event Packet
uint8 cin:4; // Code Index Number
uint8 cn:4; // Cable Number
uint8 midi[3];
} _PACKED usb_midi_event_packet;
#endif // USB_MIDI_H