Skip to content

Commit

Permalink
Move internal defs from ata.h to ata.c.
Browse files Browse the repository at this point in the history
With -fwhole-program it is not necessary to put inline functions into
    headers.  So, move the internal defs and code to ata.c.
  • Loading branch information
KevinOConnor committed Mar 23, 2008
1 parent aa7ddd7 commit f888f8c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 50 deletions.
50 changes: 49 additions & 1 deletion src/ata.c
Expand Up @@ -139,6 +139,24 @@ ata_reset(u16 device)
// 6 : no sectors left to write
// 7 : more sectors to write

struct ata_pio_command {
void *far_buffer;
u8 biosid;

u8 feature;
u8 sector_count;
u8 lba_low;
u8 lba_mid;
u8 lba_high;
u8 device;
u8 command;

u8 sector_count2;
u8 lba_low2;
u8 lba_mid2;
u8 lba_high2;
};

static int
send_cmd(struct ata_pio_command *cmd)
{
Expand Down Expand Up @@ -183,7 +201,7 @@ send_cmd(struct ata_pio_command *cmd)
return 0;
}

int
static int
ata_transfer(struct ata_pio_command *cmd)
{
DEBUGF("ata_transfer id=%d cmd=%d lba=%d count=%d buf=%p\n"
Expand Down Expand Up @@ -258,6 +276,36 @@ ata_transfer(struct ata_pio_command *cmd)
return 0;
}

inline int
ata_cmd_data(u16 biosid, u16 command, u32 lba, u16 count, void *far_buffer)
{
u8 slave = biosid % 2;

struct ata_pio_command cmd;
cmd.far_buffer = far_buffer;
cmd.biosid = biosid;

if (count >= (1<<8) || lba + count >= (1<<28)) {
cmd.sector_count2 = count >> 8;
cmd.lba_low2 = lba >> 24;
cmd.lba_mid2 = 0;
cmd.lba_high2 = 0;

command |= 0x04;
lba &= 0xffffff;
}

cmd.feature = 0;
cmd.sector_count = count;
cmd.lba_low = lba;
cmd.lba_mid = lba >> 8;
cmd.lba_high = lba >> 16;
cmd.device = ((slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0)
| ((lba >> 24) & 0xf) | ATA_CB_DH_LBA);
cmd.command = command;
return ata_transfer(&cmd);
}

// ---------------------------------------------------------------------------
// ATA/ATAPI driver : execute a packet command
// ---------------------------------------------------------------------------
Expand Down
50 changes: 1 addition & 49 deletions src/ata.h
Expand Up @@ -11,61 +11,13 @@
#include "types.h" // u16
#include "atabits.h" // ATA_CB_DH_DEV1

struct ata_pio_command {
void *far_buffer;
u8 biosid;

u8 feature;
u8 sector_count;
u8 lba_low;
u8 lba_mid;
u8 lba_high;
u8 device;
u8 command;

u8 sector_count2;
u8 lba_low2;
u8 lba_mid2;
u8 lba_high2;
};

// Function definitions
void ata_reset(u16 device);
int ata_transfer(struct ata_pio_command *cmd);
int ata_cmd_data(u16 biosid, u16 command, u32 lba, u16 count, void *far_buffer);
int ata_cmd_packet(u16 device, u8 *cmdbuf, u8 cmdlen
, u32 length, void *far_buffer);
int cdrom_read(u16 device, u32 lba, u32 count, void *far_buffer);
int cdrom_read_512(u16 device, u32 lba, u32 count, void *far_buffer);
void ata_detect();

static inline int
ata_cmd_data(u16 biosid, u16 command, u32 lba, u16 count, void *far_buffer)
{
u8 slave = biosid % 2;

struct ata_pio_command cmd;
cmd.far_buffer = far_buffer;
cmd.biosid = biosid;

if (count >= (1<<8) || lba + count >= (1<<28)) {
cmd.sector_count2 = count >> 8;
cmd.lba_low2 = lba >> 24;
cmd.lba_mid2 = 0;
cmd.lba_high2 = 0;

command |= 0x04;
lba &= 0xffffff;
}

cmd.feature = 0;
cmd.sector_count = count;
cmd.lba_low = lba;
cmd.lba_mid = lba >> 8;
cmd.lba_high = lba >> 16;
cmd.device = ((slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0)
| ((lba >> 24) & 0xf) | ATA_CB_DH_LBA);
cmd.command = command;
return ata_transfer(&cmd);
}

#endif /* __ATA_H */

0 comments on commit f888f8c

Please sign in to comment.