ReactOS  0.4.13-dev-257-gfabbd7c
prep_ide.c File Reference
#include "freeldr.h"
#include "machine.h"
#include "ppcmmu/mmu.h"
#include "prep.h"
Include dependency graph for prep_ide.c:

Go to the source code of this file.

Classes

struct  _idectl_desc
 

Macros

#define SWAP_W(x)   ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
 

Typedefs

typedef struct _idectl_desc idectl_desc
 

Functions

void ide_seek (void *extension, int low, int high)
 
void ide_rdy (void *extension)
 
void ide_drq (void *extension)
 
void ide_bsy (void *extension)
 
int ide_read (void *extension, char *buffer, int bytes)
 
void ide_setup (void *extension)
 

Variables

idectl_desc ide1_desc = { 0x800001f0 }
 

Macro Definition Documentation

◆ SWAP_W

#define SWAP_W (   x)    ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))

Definition at line 6 of file prep_ide.c.

Typedef Documentation

◆ idectl_desc

Function Documentation

◆ ide_bsy()

void ide_bsy ( void extension)

Definition at line 41 of file prep_ide.c.

41  {
42  idectl_desc *desc = (idectl_desc *)extension;
43  while( GetPhysByte(desc->port+7) & 0x80 )
44  {
45  printf("Waiting for not busy\n");
46  sync();
47  }
48 }
int GetPhysByte(int Addr)
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
void sync()
Definition: prep.c:9
#define printf
Definition: config.h:203

Referenced by ide_read(), and ide_setup().

◆ ide_drq()

void ide_drq ( void extension)

Definition at line 36 of file prep_ide.c.

36  {
37  idectl_desc *desc = (idectl_desc *)extension;
38  while( !(GetPhysByte(desc->port+7) & 0x08) ) sync();
39 }
int GetPhysByte(int Addr)
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
void sync()
Definition: prep.c:9

Referenced by ide_setup().

◆ ide_rdy()

void ide_rdy ( void extension)

Definition at line 31 of file prep_ide.c.

31  {
32  idectl_desc *desc = (idectl_desc *)extension;
33  while( !(GetPhysByte(desc->port+7) & 0x40) ) sync();
34 }
int GetPhysByte(int Addr)
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
void sync()
Definition: prep.c:9

Referenced by ide_setup().

◆ ide_read()

int ide_read ( void extension,
char buffer,
int  bytes 
)

Definition at line 50 of file prep_ide.c.

50  {
51  idectl_desc *desc = (idectl_desc *)extension;
52  short *databuf = (short *)buffer;
53  int inwords;
54 
55  ide_bsy( extension );
56  SetPhysByte(desc->port+2, bytes / desc->bytespersec);
57  SetPhysByte(desc->port+3, desc->seek_sector + 1);
58  SetPhysByte(desc->port+4, desc->seek_cylinder);
59  SetPhysByte(desc->port+5, desc->seek_cylinder >> 8);
60  SetPhysByte(desc->port+6, desc->seek_head | 0xa0);
61  SetPhysByte(desc->port+7, 0x20);
62 
63  for( inwords = 0; inwords < desc->bytespersec / sizeof(short); inwords++ ) {
64  databuf[inwords] = GetPhysHalf(desc->port);
65  }
66 
67  desc->seekto += desc->bytespersec;
68  ide_seek( extension, desc->seekto, desc->seekto >> 32 );
69 
70  return bytes - (bytes % desc->bytespersec);
71 }
void ide_bsy(void *extension)
Definition: prep_ide.c:41
GLuint buffer
Definition: glext.h:5915
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
int GetPhysHalf(paddr_t addr)
void ide_seek(void *extension, int low, int high)
Definition: prep_ide.c:17
void SetPhysByte(ULONG Addr, ULONG Data)

Referenced by PpcPrepDiskReadLogicalSectors().

◆ ide_seek()

void ide_seek ( void extension,
int  low,
int  high 
)

Definition at line 17 of file prep_ide.c.

17  {
18  idectl_desc *desc = (idectl_desc *)extension;
19  long long seekto = ((((long long)high) << 32) | (low & 0xffffffff));
20  /* order = sector, head, cylinder */
21  desc->seek_sector = seekto % desc->sectors;
22  seekto /= desc->sectors;
23  desc->seek_head = seekto % desc->heads;
24  seekto /= desc->heads;
25  desc->seek_cylinder = seekto;
26  desc->seekto = seekto;
27 }
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define seekto(pos, errstr)
Definition: mkdosfs.c:1613
#define long
Definition: qsort.c:33

Referenced by ide_read(), and PpcPrepDiskReadLogicalSectors().

◆ ide_setup()

void ide_setup ( void extension)

Definition at line 73 of file prep_ide.c.

73  {
74  idectl_desc *desc = (idectl_desc *)extension;
75  short identbuffer[256];
76  char namebuf[41];
77  short *databuf = (short *)identbuffer, in;
78  int inwords;
79 
80  ide_rdy( extension );
81  ide_bsy( extension );
82  desc->bytespersec = 512;
83  SetPhysByte(desc->port+2, 1);
84  SetPhysByte(desc->port+3, 0);
85  SetPhysByte(desc->port+4, 0);
86  SetPhysByte(desc->port+5, 0);
87  SetPhysByte(desc->port+6, 0);
88  SetPhysByte(desc->port+7, 0xec);
89  ide_drq( extension );
90 
91  for( inwords = 0; inwords < desc->bytespersec / sizeof(short); inwords++ ) {
92  in = GetPhysHalf(desc->port);
93  databuf[inwords] = SWAP_W(in);
94  sync();
95  }
96 
97  desc->cylinders = identbuffer[1];
98  desc->heads = identbuffer[3];
99  desc->sectors = identbuffer[6];
100 
101  /* Debug: Write out hard disc model */
102 
103  strncpy(namebuf, (char *)(identbuffer+0x1b), 41);
104  printf("HARD DISC MODEL: %s c,h,s %d,%d,%d\n",
105  namebuf, desc->cylinders, desc->heads, desc->sectors);
106 }
void ide_bsy(void *extension)
Definition: prep_ide.c:41
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
void ide_rdy(void *extension)
Definition: prep_ide.c:31
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
void ide_drq(void *extension)
Definition: prep_ide.c:36
int GetPhysHalf(paddr_t addr)
void sync()
Definition: prep.c:9
#define SWAP_W(x)
Definition: prep_ide.c:6
GLuint in
Definition: glext.h:9616
void SetPhysByte(ULONG Addr, ULONG Data)
#define printf
Definition: config.h:203

Referenced by PpcPrepInit().

Variable Documentation

◆ ide1_desc

idectl_desc ide1_desc = { 0x800001f0 }

Definition at line 15 of file prep_ide.c.

Referenced by PpcPrepDiskReadLogicalSectors(), and PpcPrepInit().