- update sector count before calling write completion function (SF patch #2144692)
[bochs-mirror.git] / misc / make_cmos_image.cc
blob5db528afc8e46cde9e17c530a93397f5bc9a85da
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: make_cmos_image.cc,v 1.4 2003/06/07 19:16:55 vruppert Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2001 MandrakeSoft S.A.
6 //
7 // MandrakeSoft S.A.
8 // 43, rue d'Aboukir
9 // 75002 Paris - France
10 // http://www.linux-mandrake.com/
11 // http://www.mandrakesoft.com/
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2 of the License, or (at your option) any later version.
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 // Program which generates sample CMOS image files
32 extern "C" {
33 #include <stdio.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <fcntl.h>
37 #include <unistd.h>
38 #include <stdlib.h>
42 #if 1
43 unsigned char cmos[] = {
44 0x29, 0x2b, 0x30, 0x2b, 0x16, 0x0b, 0x00, 0x01,
45 0x01, 0x96, 0x26, 0x02, 0x50, 0x80, 0x00, 0x00,
46 0x40, 0x8f, 0xf0, 0xc0, 0x3f, 0x80, 0x02, 0x00,
47 0x3c, 0x2f, 0x00, 0x4c, 0x0c, 0x10, 0x00, 0x00,
48 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49 0x00, 0x48, 0x2b, 0x03, 0x03, 0x03, 0x04, 0xce,
50 0x00, 0x3c, 0x19, 0xff, 0xff, 0xf0, 0x00, 0xf0,
51 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x7b
54 #else
55 unsigned char cmos[] = {
56 0x29, 0x2b, 0x30, 0x2b, 0x16, 0x0b, 0x00, 0x01,
57 0x01, 0x96, 0x26, 0x02, 0x50, 0x80, 0x00, 0x00,
58 0x40, 0x8f, 0xf0, 0xc0, 0x0f, 0x80, 0x02, 0x00,
59 0x3c, 0x2f, 0x00, 0x1e, 0x00, 0x04, 0xff, 0xff,
60 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x08, 0x08, 0x03, 0x03, 0x03, 0x05, 0xc5,
62 0x00, 0x3c, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x10,
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, // 0x21
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
67 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, // 50
68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 60
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 70
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
74 #endif
76 int
77 main(int argc, char *argv[])
79 int fd, ret;
81 if (argc != 2) {
82 fprintf(stderr, "usage: %s pathname\n", argv[0]);
83 exit(1);
86 fd = open(argv[1], O_WRONLY | O_CREAT
87 #ifdef O_BINARY
88 | O_BINARY
89 #endif
90 , S_IRUSR | S_IWUSR
92 if (fd < 0) {
93 perror("trying to open cmos image file to write.\n");
94 exit(1);
97 ret = write(fd, cmos, sizeof(cmos));
98 if (ret != sizeof(cmos)) {
99 perror("write() did not write all CMOS data.\n");
100 exit(1);
102 printf("CMOS data successfuly written to file '%s'.\n", argv[1]);