Changeset e092dc5 in mainline


Ignore:
Timestamp:
2010-12-30T14:26:29Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e682af1
Parents:
d770deb
Message:

Fix incorrect control block base address. Add base adresses for three more legacy ATA controllers. Allow selecting ATA controller via command line argument.

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/init/init.c

    rd770deb re092dc5  
    6161
    6262#define DATA_FS_TYPE      "fat"
    63 #define DATA_DEVICE       "bd/disk0"
     63#define DATA_DEVICE       "bd/ata1disk0"
    6464#define DATA_MOUNT_POINT  "/data"
    6565
  • uspace/srv/bd/ata_bd/ata_bd.c

    rd770deb re092dc5  
    7171#define NAMESPACE  "bd"
    7272
     73/** Number of defined legacy controller base addresses. */
     74#define LEGACY_CTLS 4
     75
    7376/** Physical block size. Should be always 512. */
    7477static const size_t block_size = 512;
     
    7881
    7982/** I/O base address of the command registers. */
    80 static uintptr_t cmd_physical = 0x1f0;
     83static uintptr_t cmd_physical;
    8184/** I/O base address of the control registers. */
    82 static uintptr_t ctl_physical = 0x170;
     85static uintptr_t ctl_physical;
     86
     87/** I/O base addresses for legacy (ISA-compatible) controllers. */
     88static ata_base_t legacy_base[LEGACY_CTLS] = {
     89        { 0x1f0, 0x3f0 },
     90        { 0x170, 0x370 },
     91        { 0x1e8, 0x3e8 },
     92        { 0x168, 0x368 }
     93};
    8394
    8495static ata_cmd_t *cmd;
     
    8899static disk_t disk[MAX_DISKS];
    89100
     101static void print_syntax(void);
    90102static int ata_bd_init(void);
    91103static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall);
     
    111123        int i, rc;
    112124        int n_disks;
     125        unsigned ctl_num;
     126        char *eptr;
    113127
    114128        printf(NAME ": ATA disk driver\n");
    115129
    116         printf("I/O address %p/%p\n", (void *) ctl_physical,
    117             (void *) cmd_physical);
     130        if (argc > 1) {
     131                ctl_num = strtoul(argv[1], &eptr, 0);
     132                if (*eptr != '\0' || ctl_num == 0 || ctl_num > 4) {
     133                        printf("Invalid argument.\n");
     134                        print_syntax();
     135                        return -1;
     136                }
     137        } else {
     138                ctl_num = 1;
     139        }
     140
     141        cmd_physical = legacy_base[ctl_num - 1].cmd;
     142        ctl_physical = legacy_base[ctl_num - 1].ctl;
     143
     144        printf("I/O address %p/%p\n", (void *) cmd_physical,
     145            (void *) ctl_physical);
    118146
    119147        if (ata_bd_init() != EOK)
     
    140168                        continue;
    141169               
    142                 snprintf(name, 16, "%s/disk%d", NAMESPACE, i);
     170                snprintf(name, 16, "%s/ata%udisk%d", NAMESPACE, ctl_num, i);
    143171                rc = devmap_device_register(name, &disk[i].devmap_handle);
    144172                if (rc != EOK) {
     
    161189        /* Not reached */
    162190        return 0;
     191}
     192
     193
     194static void print_syntax(void)
     195{
     196        printf("Syntax: " NAME " <controller_number>\n");
     197        printf("Controller number = 1..4\n");
    163198}
    164199
  • uspace/srv/bd/ata_bd/ata_bd.h

    rd770deb re092dc5  
    3939#include <fibril_synch.h>
    4040#include <str.h>
     41
     42/** Base addresses for ATA I/O blocks. */
     43typedef struct {
     44        uintptr_t cmd;  /**< Command block base address. */
     45        uintptr_t ctl;  /**< Control block base address. */
     46} ata_base_t;
    4147
    4248/** Timeout definitions. Unit is 10 ms. */
     
    8187} block_coord_t;
    8288
     89/** ATA device state structure. */
    8390typedef struct {
    8491        bool present;
Note: See TracChangeset for help on using the changeset viewer.