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