Logo Search packages:      
Sourcecode: makebootfat version File versions  Download package

disk.h

/*
 * This file is part of the Advance project.
 *
 * Copyright (C) 2004, 2005 Andrea Mazzoleni
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details. 
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __DISK_H
#define __DISK_H

/**
 * Sector size in bytes.
 */
#define SECTOR_SIZE 512

00029 struct disk_geometry {
00030       unsigned sectors; /**< Track size in number of sector. Max is 63. */
00031       unsigned heads; /**< Cylinder size in number of tracks. Max is 256. */
00032       unsigned cylinders; /**< Number of cylinder. Max is 1024. */
00033       unsigned size; /**< Total size in number of sectors. With the limits 63/256/1024 the max size approx. 8 GBytes. */
00034       unsigned start; /**< Number of sectors before the accessible space. */
00035       unsigned char drive; /**< BIOS drive number. 0x0 for first floppy, 0x80 for first harddisk. */
};

00038 struct disk_cache {
00039       unsigned char* data; /**< Data to write. */
00040       unsigned pos; /**< Position of the data in sectors. */
00041       unsigned size; /**< Size of the data in sectors. */
00042       struct disk_cache* next; /**< Next concatenated write. */
};

00045 struct disk_handle {
#ifdef __WIN32__
      void* handle; /**< Handle. */
#else
00049       int handle; /**< Handle. */
#endif
00051       struct disk_geometry geometry; /**< Device geometry. */
00052       char device[512]; /**< Device name. */
00053       void* ope_context; /**< Context of the read/write operations callback. */
00054       void (*ope_callback)(void* context, int operation, unsigned pos, unsigned size); /**< Callback for the read/write operations. */

00056       struct disk_cache* cache_list; /**< Delayed write. */
00057       unsigned cache_begin; /**< Start of the delayed write in sectors. */
00058       unsigned cache_end; /**< End of the delayed write in sectors. */
};

unsigned le_uint16_read(const void* ptr);
unsigned le_uint32_read(const void* ptr);
void le_uint16_write(void* ptr, unsigned v);
void le_uint32_write(void* ptr, unsigned v);

struct disk_handle* disk_open(const char* dev);
int disk_close(struct disk_handle* h);
struct disk_handle* disk_find(void);
int disk_read(struct disk_handle* h, unsigned pos, void* data, unsigned size);
int disk_write(struct disk_handle* h, unsigned pos, const void* data, unsigned size);

#endif


Generated by  Doxygen 1.6.0   Back to index