mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-06 18:30:51 +00:00
Can work on floppy image or directly on second level binary
This commit is contained in:
parent
a700a2f1f7
commit
4c85e103ed
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
static void usage(int argc, char** argv)
|
static void usage(int argc, char** argv)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s <image> <cmdline>\n", argv[0]);
|
fprintf(stderr, "Usage: %s <file> <cmdline>\n", argv[0]);
|
||||||
fprintf(stderr, "Usage: %s -r <image>\n", argv[0]);
|
fprintf(stderr, "Usage: %s -r <file>\n", argv[0]);
|
||||||
fprintf(stderr, "\n Allows to set the kernel command line <cmdline>\n");
|
fprintf(stderr, "\n Allows to set the kernel command line <cmdline>\n");
|
||||||
fprintf(stderr, " into the floppy image <image>\n");
|
fprintf(stderr, " into the floppy image or the second level file\n");
|
||||||
fprintf(stderr, " <image> can be a file or a device (/dev/fd0)\n");
|
fprintf(stderr, " <image> can be a file or a device (/dev/fd0)\n");
|
||||||
fprintf(stderr, " with \"-r\" flag, display current command line\n");
|
fprintf(stderr, " with \"-r\" flag, display current command line\n");
|
||||||
fprintf(stderr, "\n Examples:\n");
|
fprintf(stderr, "\n Examples:\n");
|
||||||
@ -35,10 +35,11 @@ static void usage(int argc, char** argv)
|
|||||||
fprintf(stderr, "\nbuild: \n%s\n", SIGNATURE);
|
fprintf(stderr, "\nbuild: \n%s\n", SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_cmdline(char* image, char* cmdline, off_t base)
|
int set_cmdline(char* image, char* cmdline)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
int drive, second, size;
|
||||||
|
|
||||||
fd = open(image, O_RDWR);
|
fd = open(image, O_RDWR);
|
||||||
|
|
||||||
@ -48,12 +49,20 @@ int set_cmdline(char* image, char* cmdline, off_t base)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = lseek(fd, base, SEEK_SET);
|
/* can work on an image or directly on second level file */
|
||||||
if (ret == -1)
|
|
||||||
|
ret = emile_first_get_param(fd, &drive, &second, &size);
|
||||||
|
if (ret == EEMILE_UNKNOWN_FIRST)
|
||||||
{
|
{
|
||||||
perror("Cannot go to buffer offset");
|
/* should be a second level file */
|
||||||
close(fd);
|
|
||||||
return 3;
|
ret = lseek(fd, 0, SEEK_SET);
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
perror("Cannot go to buffer offset");
|
||||||
|
close(fd);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = emile_second_set_cmdline(fd, cmdline);
|
ret = emile_second_set_cmdline(fd, cmdline);
|
||||||
@ -63,40 +72,50 @@ int set_cmdline(char* image, char* cmdline, off_t base)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_cmdline(char* image, off_t base)
|
int get_cmdline(char* image)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
char cmdline[255];
|
char cmdline[255];
|
||||||
|
int drive, second, size;
|
||||||
|
|
||||||
fd = open(image, O_RDONLY);
|
fd = open(image, O_RDONLY);
|
||||||
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
perror("Cannot open image file");
|
perror("Cannot open image file");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = lseek(fd, base, SEEK_SET);
|
/* can work on an image or directly on second level file */
|
||||||
if (ret == -1)
|
|
||||||
|
ret = emile_first_get_param(fd, &drive, &second, &size);
|
||||||
|
if (ret == EEMILE_UNKNOWN_FIRST)
|
||||||
{
|
{
|
||||||
perror("Cannot go to buffer offset");
|
/* should be a second level file */
|
||||||
close(fd);
|
|
||||||
return 3;
|
ret = lseek(fd, 0, SEEK_SET);
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
perror("Cannot go to buffer offset");
|
||||||
|
close(fd);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = emile_second_get_cmdline(fd, cmdline);
|
ret = emile_second_get_cmdline(fd, cmdline);
|
||||||
|
if (ret == -1)
|
||||||
|
return 4;
|
||||||
|
|
||||||
printf("Current command line: \"%s\"\n", cmdline);
|
printf("Current command line: \"%s\"\n", cmdline);
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
off_t base = FIRST_LEVEL_SIZE;
|
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
{
|
{
|
||||||
usage(argc, argv);
|
usage(argc, argv);
|
||||||
@ -104,9 +123,9 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(argv[1], "-r") == 0)
|
if (strcmp(argv[1], "-r") == 0)
|
||||||
ret = get_cmdline(argv[2], base);
|
ret = get_cmdline(argv[2]);
|
||||||
else
|
else
|
||||||
ret = set_cmdline(argv[1], argv[2], base);
|
ret = set_cmdline(argv[1], argv[2]);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ static char *parity[3] = { "None", "Odd", "Even" };
|
|||||||
static void usage(int argc, char** argv)
|
static void usage(int argc, char** argv)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage:\n");
|
fprintf(stderr, "Usage:\n");
|
||||||
fprintf(stderr, "\n%s <image> --display [--width <width>] [--height <height>] [--depth <depth>]\n", argv[0]);
|
fprintf(stderr, "\n%s <file> --display [--width <width>] [--height <height>] [--depth <depth>]\n", argv[0]);
|
||||||
fprintf(stderr, " Enable output to display and set configuration\n");
|
fprintf(stderr, " Enable output to display and set configuration\n");
|
||||||
fprintf(stderr, "\n%s <image> --modem [--bitrate <bitrate>] [--datasize <datasize>] [--parity <parity>] [--stopbits <stopbits>]\n", argv[0]);
|
fprintf(stderr, "\n%s <image> --modem [--bitrate <bitrate>] [--datasize <datasize>] [--parity <parity>] [--stopbits <stopbits>]\n", argv[0]);
|
||||||
fprintf(stderr, " Enable output to serial port 0 (modem) and set configuration\n");
|
fprintf(stderr, " Enable output to serial port 0 (modem) and set configuration\n");
|
||||||
@ -51,6 +51,7 @@ static int display_output(char* image)
|
|||||||
int parity1;
|
int parity1;
|
||||||
int stopbits1;
|
int stopbits1;
|
||||||
int gestaltid;
|
int gestaltid;
|
||||||
|
int drive, second, size;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
@ -59,16 +60,24 @@ static int display_output(char* image)
|
|||||||
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
perror("Cannot open image file");
|
perror("Cannot open file");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = lseek(fd, FIRST_LEVEL_SIZE, SEEK_SET);
|
/* can work on an image or directly on second level file */
|
||||||
if (ret == -1)
|
|
||||||
|
ret = emile_first_get_param(fd, &drive, &second, &size);
|
||||||
|
if (ret == EEMILE_UNKNOWN_FIRST)
|
||||||
{
|
{
|
||||||
perror("Cannot go to buffer offset");
|
/* should be a second level file */
|
||||||
close(fd);
|
|
||||||
return 3;
|
ret = lseek(fd, 0, SEEK_SET);
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
perror("Cannot go to buffer offset");
|
||||||
|
close(fd);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = emile_second_get_output(fd, &console_mask, &bitrate0,
|
ret = emile_second_get_output(fd, &console_mask, &bitrate0,
|
||||||
|
Loading…
Reference in New Issue
Block a user