blob: b7651821e0fb9ad1cb8b4c915d679626ccb41110 [file] [log] [blame]
adamdunkels48f23f02004-02-16 20:58:54 +00001/**
2 * \addtogroup c64fs
3 * @{
4 *
5 */
6
7/**
8 * \file
9 * C64 direct disk I/O.
10 * \author Adam Dunkels <adam@dunkels.com>
11 *
12 */
13
adamdunkels74c1ecb2003-08-04 00:12:50 +000014/*
15 * Copyright (c) 2003, Adam Dunkels.
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above
24 * copyright notice, this list of conditions and the following
25 * disclaimer in the documentation and/or other materials provided
26 * with the distribution.
adamdunkels48f23f02004-02-16 20:58:54 +000027 * 3. The name of the author may not be used to endorse or promote
adamdunkels74c1ecb2003-08-04 00:12:50 +000028 * products derived from this software without specific prior
29 * written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
32 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
35 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
37 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
43 * This file is part of the Contiki desktop OS
44 *
adamdunkels48f23f02004-02-16 20:58:54 +000045 * $Id: c64-dio.c,v 1.2 2004/02/16 20:58:54 adamdunkels Exp $
adamdunkels74c1ecb2003-08-04 00:12:50 +000046 *
47 */
48
49#include "c64-dio.h"
50#include "c64-dio-asm.h"
51
52/*-----------------------------------------------------------------------------------*/
adamdunkels48f23f02004-02-16 20:58:54 +000053/**
54 * Read a block of data (256 bytes) from the disk.
55 *
56 * \param track The track of the disk block to be read.
57 *
58 * \param sector The sector of the disk block to be read.
59 *
60 * \param ptr A pointer to a buffer than must be able to accomodate
61 * 256 bytes of data.
62 *
63 * \return An error code or C64_DIO_OK if the data was successfully
64 * read.
65 */
66/*-----------------------------------------------------------------------------------*/
67unsigned char
adamdunkels74c1ecb2003-08-04 00:12:50 +000068c64_dio_read_block(unsigned char track,
69 unsigned char sector,
70 unsigned char *ptr)
71{
72 c64_dio_asm_track = track;
73 c64_dio_asm_sector = sector;
74 c64_dio_asm_ptr = ptr;
adamdunkels48f23f02004-02-16 20:58:54 +000075 return c64_dio_asm_read_block();
adamdunkels74c1ecb2003-08-04 00:12:50 +000076}
77/*-----------------------------------------------------------------------------------*/
adamdunkels48f23f02004-02-16 20:58:54 +000078/**
79 * Write a block of data (256 bytes) to the disk.
80 *
81 * \param track The track of the disk block to be written.
82 *
83 * \param sector The sector of the disk block to be written.
84 *
85 * \param ptr A pointer to a buffer containing the 256 bytes of data
86 * to be written.
87 *
88 * \return An error code or C64_DIO_OK if the data was successfully
89 * written.
90 */
91/*-----------------------------------------------------------------------------------*/
92unsigned char
adamdunkels74c1ecb2003-08-04 00:12:50 +000093c64_dio_write_block(unsigned char track,
94 unsigned char sector,
95 unsigned char *ptr)
96{
97 c64_dio_asm_track = track;
98 c64_dio_asm_sector = sector;
99 c64_dio_asm_ptr = ptr;
adamdunkels48f23f02004-02-16 20:58:54 +0000100 return c64_dio_asm_write_block();
adamdunkels74c1ecb2003-08-04 00:12:50 +0000101}
102/*-----------------------------------------------------------------------------------*/
adamdunkels48f23f02004-02-16 20:58:54 +0000103/**
104 * Initialize the direct disk I/O routines for a particular disk drive.
105 *
106 * This function must be called before any of the other direct disk
107 * I/O functions can be used.
108 *
109 * \param drive The drive number of the disk drive for which the
110 * direct disk I/O should be enabled.
111 */
112/*-----------------------------------------------------------------------------------*/
adamdunkels74c1ecb2003-08-04 00:12:50 +0000113void
114c64_dio_init(unsigned char drive)
115{
116 c64_dio_asm_init(drive);
117}
118/*-----------------------------------------------------------------------------------*/
adamdunkels48f23f02004-02-16 20:58:54 +0000119/** @} */