2 sltime utility replacement for Sharp Zaurus SL-C7x0/860
4 Copyright 2004 Alexander Chukov <sash@cacko.biz>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
20 #include <sys/ioctl.h>
21 #include <sys/types.h>
27 #define CONFIG_MTD_NAND_LOGICAL_ADDRESS_ACCESS
30 #define APM_IOC_SETRTC 0x4146
31 #define APM_IOC_GETRTC 0x4147
33 static int open_mtd(void)
39 if((fd = open("/dev/mtd1", O_RDWR)) == -1) {
44 /* Fill in MTD device capability structure */
45 if(ioctl(fd, MEMGETINFO, &meminfo) != 0) {
51 /* Make sure device page sizes are valid */
52 if( !(meminfo.oobsize == 16 && meminfo.oobblock == 512) &&
53 !(meminfo.oobsize == 8 && meminfo.oobblock == 256) ) {
54 printf("Unknown flash (not normal NAND)\n");
62 int main(int argc, char *argv[])
67 struct read_laddr_info_user rinfo = {0x4C004, 4, (unsigned char *) &setime};
71 if (ioctl(mfd, MEMREADLADDR, &rinfo) != 0) {
72 perror("ioctl(MEMREADLADDR)");
77 fd = open("/dev/apm_bios", O_RDWR);
78 //setime += ioctl(fd, APM_IOC_GETRTC, 0);
79 ioctl(fd, APM_IOC_SETRTC, &setime);
84 } else if (strcmp(argv[1], "-clear") == 0) {
85 fd = open("/dev/apm_bios", O_RDWR);
87 tv.tv_sec = 1075658510;
90 ioctl(fd, APM_IOC_SETRTC, (void*)&setime);
92 } else if (strcmp(argv[1], "-set") == 0) {
96 if (ioctl(mfd, MEMWRITELADDR, &rinfo) != 0) {
97 perror("ioctl(MEMWRITELADDR)");
103 fprintf(stderr, "Usage:\n%s [-set|-clear]\n", argv[0]);