ATA.h revision d3f27239
1/*
2 * Copyright 2002-2003, Thomas Kurschel. All rights reserved.
3 * Copyright 2003-2009, Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT License.
5 */
6#ifndef __ATA_H__
7#define __ATA_H__
8
9#include <device_manager.h>
10#include <KernelExport.h>
11
12// Controller Driver Node
13
14// attributes:
15
16// node type
17#define ATA_BUS_TYPE_NAME "bus/ata/v1"
18// maximum number of devices connected to controller (uint8, optional, default:2)
19#define ATA_CONTROLLER_MAX_DEVICES_ITEM "ata/max_devices"
20// set to not-0 if DMA is supported (uint8, optional, default:0)
21#define ATA_CONTROLLER_CAN_DMA_ITEM "ata/can_DMA"
22// name of controller (string, required)
23#define ATA_CONTROLLER_CONTROLLER_NAME_ITEM "ata/controller_name"
24
25union ata_task_file;
26typedef unsigned int ata_reg_mask;
27
28// channel cookie, issued by ata bus manager
29typedef void* ata_channel;
30
31// interface of controller driver
32typedef struct {
33	driver_module_info info;
34
35	void (*set_channel)(void *cookie, ata_channel channel);
36
37	status_t (*write_command_block_regs)(void *channelCookie,
38		union ata_task_file *file, ata_reg_mask mask);
39	status_t (*read_command_block_regs)(void *channelCookie,
40		union ata_task_file *file, ata_reg_mask mask);
41
42	uint8 (*get_altstatus)(void *channelCookie);
43	status_t (*write_device_control)(void *channelCookie, uint8 val);
44
45	status_t (*write_pio)(void *channelCookie, uint16 *data, int count,
46		bool force16Bit);
47	status_t (*read_pio)(void *channelCookie, uint16 *data, int count,
48		bool force16Bit);
49
50	status_t (*prepare_dma)(void *channelCookie, const physical_entry *sg_list,
51		size_t sg_list_count, bool write);
52	status_t (*start_dma)(void *channelCookie);
53	status_t (*finish_dma)(void *channelCookie);
54} ata_controller_interface;
55
56
57// Interface for Controller Driver
58
59// interface of bus manager as seen from controller driver
60// use this interface as the fixed consumer of your controller driver
61typedef struct {
62	driver_module_info info;
63
64	// status - status read from controller (_not_ alt_status, as reading
65	//          normal status acknowledges IRQ request of device)
66	status_t	(*interrupt_handler)(ata_channel channel, uint8 status);
67} ata_for_controller_interface;
68
69#define ATA_FOR_CONTROLLER_MODULE_NAME "bus_managers/ata/controller/driver_v1"
70
71#endif	/* __ATA_H__ */
72