adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 1 | /** |
| 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 | |
adamdunkels | 74c1ecb | 2003-08-04 00:12:50 +0000 | [diff] [blame] | 14 | /* |
| 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. |
adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 27 | * 3. The name of the author may not be used to endorse or promote |
adamdunkels | 74c1ecb | 2003-08-04 00:12:50 +0000 | [diff] [blame] | 28 | * 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 | * |
adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 45 | * $Id: c64-dio.c,v 1.2 2004/02/16 20:58:54 adamdunkels Exp $ |
adamdunkels | 74c1ecb | 2003-08-04 00:12:50 +0000 | [diff] [blame] | 46 | * |
| 47 | */ |
| 48 | |
| 49 | #include "c64-dio.h" |
| 50 | #include "c64-dio-asm.h" |
| 51 | |
| 52 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 53 | /** |
| 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 | /*-----------------------------------------------------------------------------------*/ |
| 67 | unsigned char |
adamdunkels | 74c1ecb | 2003-08-04 00:12:50 +0000 | [diff] [blame] | 68 | c64_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; |
adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 75 | return c64_dio_asm_read_block(); |
adamdunkels | 74c1ecb | 2003-08-04 00:12:50 +0000 | [diff] [blame] | 76 | } |
| 77 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 78 | /** |
| 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 | /*-----------------------------------------------------------------------------------*/ |
| 92 | unsigned char |
adamdunkels | 74c1ecb | 2003-08-04 00:12:50 +0000 | [diff] [blame] | 93 | c64_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; |
adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 100 | return c64_dio_asm_write_block(); |
adamdunkels | 74c1ecb | 2003-08-04 00:12:50 +0000 | [diff] [blame] | 101 | } |
| 102 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 103 | /** |
| 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 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | 74c1ecb | 2003-08-04 00:12:50 +0000 | [diff] [blame] | 113 | void |
| 114 | c64_dio_init(unsigned char drive) |
| 115 | { |
| 116 | c64_dio_asm_init(drive); |
| 117 | } |
| 118 | /*-----------------------------------------------------------------------------------*/ |
adamdunkels | 48f23f0 | 2004-02-16 20:58:54 +0000 | [diff] [blame] | 119 | /** @} */ |