/* $Id: atarwbuf.c 73 2015-12-20 21:17:34Z bird $ */ /** @file * Tests writing the ATA buffer. */ /* * Copyright (c) 2015 knut st. osmundsen * * 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 3 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, see * */ #include #include #include #include #include #include #include "atalib.h" int main(int argc, char **argv) { static uint8_t s_abBuf1[512]; static uint8_t s_abBuf2[512]; int rc; unsigned i; rc = AtaInitFromArgv(1, argc, argv); if (rc != 0) return 2; /* * Write and read back. */ for (i = 0; i < 512; i++) s_abBuf1[i] = (uint8_t)i; rc = AtaWriteBuffer(s_abBuf1, 1 /*fExtraChecks*/); if (rc != 0) return 1; rc = AtaReadBuffer(s_abBuf2, 1 /*fExtraChecks*/); if (rc != 0) return 1; if (memcmp(s_abBuf1, s_abBuf2, sizeof(s_abBuf1)) == 0) printf("Initial buffer write and read-back worked\n"); else { fprintf(stderr, "error: Initial buffer write and read-back failed!\n"); return 1; } return 0; }