/*
 * $ZEL$
 */

#include "test_3100.h"

/*
static int
check_rw_remote(struct path* path)
{
    struct vmespace space;
    int res, size;

    printf("testing sdram over VME\n");
    if (vme_probe(path, VMESTART)) return 0;

    space.am=0x9;
    space.datasize=4;
    space.swap=1;
    space.mapit=0;
    space.mindmalen=-1;
    res=ioctl(path->p, SIS1100_SETVMESPACE, &space);
    if (res) {
        printf("SETVMESPACE(%s): %s\n", path->name, strerror(errno));
        return -1;
    }
    if (check_rw_single(path, VMESTART, 10000)<0) return -1;

    space.am=0xb;
    res=ioctl(path->p, SIS1100_SETVMESPACE, &space);
    if (res) {
        printf("SETVMESPACE(%s): %s\n", path->name, strerror(errno));
        return -1;
    }
    size=1;
    while (check_rw_block(path, VMESTART, size)>=0) {
        printf(".");
        fflush(stdout);
        size<<=4;
    }
    printf("OK.\n");
    return 0;
}
*/

static int
check_rw_ram(struct path* path)
{
    printf("testing sdram\n");
    if (check_rw_single(path, 0, 1000)<0) return -1;
    if (check_r_block(path, 0, bufsize)<0) return -1;
    if (check_w_block(path, 0, bufsize)<0) return -1;
    printf("OK.\n");
    return 0;
}

static int
check_rw_ctrl(struct path* path)
{
    return 0;
}

static int
check_rw_dsp(struct path* path)
{
    return 0;
}

int
check_rw(struct path* path)
{
    int res;
    switch (path->type) {
    case sis1100_subdev_remote:
        /*if ((res=check_rw_remote(path))<0) return res;*/
        break;
    case sis1100_subdev_ram:
        if ((res=check_rw_ram(path))<0) return res;
        break;
#if MAJORVERSION >= 2
    case sis1100_subdev_ctrl:
        if ((res=check_rw_ctrl(path))<0) return res;
        break;
#endif
    case sis1100_subdev_dsp:
        if ((res=check_rw_dsp(path))<0) return res;
        break;
    default:
        printf("check_rw: %s has unknown type %d\n",
                path->name, path->type);
        return -1;
    }
    return 0;
}

