#ifndef _KERNEL_DEVICE_IDEDRV_H
#define _KERNEL_DEVICE_IDEDRV_H

#include <libk/std.h>
#include <proc/proc.h>
#include <proc/reschedule.h>

#define IDE_PROBE_AVAIL (1 << 0)
#define IDE_PROBE_LBA48 (1 << 1)

struct device;

struct idedrv_init {
  bool lba48;
  size_t sector_count;
  size_t sector_size;
  uint16_t io, ctrl;
  uint8_t devno;
};

struct idedrv {
  bool lba48;
  size_t sector_count;
  size_t sector_size;
  uint16_t io, ctrl;
  uint8_t devno;
};

struct ide_probe {
  uint16_t flags;
  size_t sector_count;
  size_t sector_size;
  uint16_t io, ctrl;
  uint8_t devno;
};

bool idedrv_init (struct device* device, void* arg);

void idedrv_fini (struct device* device);

int idedrv_read (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
                 void* a2, void* a3, void* a4);

int idedrv_write (struct device* device, struct proc* proc, struct reschedule_ctx* rctx, void* a1,
                  void* a2, void* a3, void* a4);

int idedrv_get_device_type (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
                            void* a1, void* a2, void* a3, void* a4);

int idedrv_get_sector_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
                            void* a1, void* a2, void* a3, void* a4);

int idedrv_get_size (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
                     void* a1, void* a2, void* a3, void* a4);

void ide_probe (uint16_t io, uint16_t ctrl, uint8_t devno, struct ide_probe* probe);

#endif // _KERNEL_DEVICE_IDEDRV_H
