initial import
[create_vflash7.git] / source / main.c
blobd1c260d59ba59973f68a3d2eb1d396f377378b51
2 /*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; version 2 of the License.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #include <unistd.h>
19 #include <psl1ght/lv2/net.h>
21 #include <lv1_hvcall.h>
22 #include <lv2_syscall.h>
23 #include <udp_printf.h>
25 #define VFLASH_DEV_ID 0x100000000000001ull
26 #define VFLASH_REGION_START_SECTOR 0x80000ull
27 #define VFLASH_REGION_SECTOR_COUNT 0x5000000ull /* 40GB for my beloved Linux */
28 #define VFLASH_REGION_LAID 0x1070000002000001ull
31 * main
33 int main(int argc, char **argv)
35 uint32_t dev_handle;
36 uint64_t region_id;
37 int result;
39 netInitialize();
41 udp_printf_init();
43 PRINTF("%s:%d: start\n", __func__, __LINE__);
45 dev_handle = 0;
47 result = lv2_storage_open(VFLASH_DEV_ID, &dev_handle);
48 if (result) {
49 PRINTF("%s:%d: lv2_storage_open failed (0x%08x)\n", __func__, __LINE__, result);
50 goto done;
53 result = lv2_storage_create_region(dev_handle, VFLASH_REGION_START_SECTOR, VFLASH_REGION_SECTOR_COUNT,
54 0, VFLASH_REGION_LAID, &region_id);
55 if (result) {
56 PRINTF("%s:%d: lv2_storage_create_region failed (0x%08x)\n", __func__, __LINE__, result);
57 goto done;
60 PRINTF("%s:%d: region_id (%d)\n", __func__, __LINE__, region_id);
62 PRINTF("%s:%d: end\n", __func__, __LINE__);
64 done:
66 result = lv2_storage_close(dev_handle);
67 if (result)
68 PRINTF("%s:%d: lv2_storage_close failed (0x%08x)\n", __func__, __LINE__, result);
70 udp_printf_deinit();
72 netDeinitialize();
74 return 0;