mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-03 12:31:57 +00:00
EM06 header type: all is stored as text
This commit is contained in:
parent
b08a5c17e6
commit
9589271a29
164
second/config.c
164
second/config.c
@ -3,49 +3,171 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <config.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "config.h"
|
||||||
#if defined(USE_CLI) && defined(__LINUX__)
|
#if defined(USE_CLI) && defined(__LINUX__)
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "cli.h"
|
#include "cli.h"
|
||||||
#endif
|
#endif
|
||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
|
|
||||||
static char kernel[256];
|
#define COMMAND_LINE_LENGTH 256
|
||||||
static char ramdisk[256];
|
char parameters[COMMAND_LINE_LENGTH];
|
||||||
|
|
||||||
|
static char *read_line(char *s)
|
||||||
|
{
|
||||||
|
int read = 0;
|
||||||
|
while (*s && (*s != '\n'))
|
||||||
|
{
|
||||||
|
read++;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
return s + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *read_word(char *line, char **next)
|
||||||
|
{
|
||||||
|
char *word;
|
||||||
|
|
||||||
|
while ( (*line == ' ') || (*line == '\t') || (*line == '\n') )
|
||||||
|
line++;
|
||||||
|
|
||||||
|
word = line;
|
||||||
|
|
||||||
|
while ( *line && (*line != ' ') && (*line != '\t') && (*line != '\n') )
|
||||||
|
line++;
|
||||||
|
|
||||||
|
*next = line;
|
||||||
|
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *decode_serial(char* s, int *baudrate, int *parity, int *datasize)
|
||||||
|
{
|
||||||
|
*baudrate = strtol(s, &s, 0);
|
||||||
|
switch(*s)
|
||||||
|
{
|
||||||
|
case 'n':
|
||||||
|
case 'N':
|
||||||
|
*parity = 0;
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
case 'O':
|
||||||
|
*parity = 1;
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
case 'E':
|
||||||
|
*parity = 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*parity = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
*datasize = strtol(s, &s, 0);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int read_config_modem(char *conf, int *bitrate, int *parity, int *datasize)
|
||||||
|
{
|
||||||
|
char *next_word, *next_line, *name, *property;
|
||||||
|
int name_len;
|
||||||
|
|
||||||
|
next_line = conf;
|
||||||
|
|
||||||
|
while (*next_line)
|
||||||
|
{
|
||||||
|
next_word = next_line;
|
||||||
|
next_line = read_line(next_line);
|
||||||
|
name = read_word(next_word, &next_word);
|
||||||
|
name_len = next_word - name;
|
||||||
|
property = read_word(next_word, &next_word);
|
||||||
|
|
||||||
|
if (strncmp(name, "modem", name_len) == 0)
|
||||||
|
{
|
||||||
|
decode_serial(property, bitrate, parity, datasize);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int read_config_printer(char *conf, int *bitrate, int *parity, int *datasize)
|
||||||
|
{
|
||||||
|
char *next_word, *next_line, *name, *property;
|
||||||
|
int name_len;
|
||||||
|
next_line = conf;
|
||||||
|
|
||||||
|
while (*next_line)
|
||||||
|
{
|
||||||
|
next_word = next_line;
|
||||||
|
next_line = read_line(next_line);
|
||||||
|
name = read_word(next_word, &next_word);
|
||||||
|
name_len = next_word - name;
|
||||||
|
property = read_word(next_word, &next_word);
|
||||||
|
|
||||||
|
if (strncmp(name, "printer", name_len) == 0)
|
||||||
|
{
|
||||||
|
decode_serial(property, bitrate, parity, datasize);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int read_config(emile_l2_header_t* info,
|
int read_config(emile_l2_header_t* info,
|
||||||
char **kernel_path, char **command_line, char **ramdisk_path)
|
char **kernel_path, char **command_line, char **ramdisk_path)
|
||||||
{
|
{
|
||||||
|
char *next_word, *next_line, *name, *property;
|
||||||
|
|
||||||
if (!EMILE_COMPAT(EMILE_05_SIGNATURE, info->signature))
|
if (!EMILE_COMPAT(EMILE_05_SIGNATURE, info->signature))
|
||||||
{
|
{
|
||||||
printf("Bad header signature !\n");
|
printf("Bad header signature !\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->gestaltID != 0)
|
next_line = info->configuration;
|
||||||
|
|
||||||
|
*ramdisk_path = NULL;
|
||||||
|
*kernel_path = NULL;
|
||||||
|
*command_line = NULL;
|
||||||
|
while (*next_line)
|
||||||
{
|
{
|
||||||
machine_id = info->gestaltID;
|
next_word = next_line;
|
||||||
|
next_line = read_line(next_line);
|
||||||
|
*(next_line - 1) = 0;
|
||||||
|
|
||||||
|
name = read_word(next_word, &next_word);
|
||||||
|
*next_word++ = 0;
|
||||||
|
|
||||||
|
property = read_word(next_word, &next_word);
|
||||||
|
*next_word++ = 0;
|
||||||
|
|
||||||
|
if (strcmp(name, "kernel") == 0)
|
||||||
|
{
|
||||||
|
*kernel_path = property;
|
||||||
|
#if defined(USE_CLI) && defined(__LINUX__)
|
||||||
|
strncpy(parameters, next_word, COMMAND_LINE_LENGTH);
|
||||||
|
*command_line = parameters;
|
||||||
|
#else
|
||||||
|
command_line = next_word;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (strcmp(name, "initrd") == 0)
|
||||||
|
{
|
||||||
|
*ramdisk_path = property;
|
||||||
|
}
|
||||||
|
else if (strcmp(name, "gestaltID") == 0)
|
||||||
|
{
|
||||||
|
machine_id = strtol(property, NULL, 0);
|
||||||
printf("User forces gestalt ID to %ld\n", machine_id);
|
printf("User forces gestalt ID to %ld\n", machine_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(kernel, "block:(fd0)0x%x", info->kernel_image_offset);
|
|
||||||
*kernel_path = kernel;
|
|
||||||
if (info->ramdisk_size == 0)
|
|
||||||
*ramdisk_path = NULL;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf(ramdisk, "block:(fd0)0x%x,0x%x",
|
|
||||||
info->ramdisk_offset,
|
|
||||||
info->ramdisk_size);
|
|
||||||
*ramdisk_path = ramdisk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("kernel %s\n", *kernel_path);
|
printf("kernel %s\n", *kernel_path);
|
||||||
if (*ramdisk)
|
printf("initrd %s\n", *ramdisk_path);
|
||||||
printf("ramdisk %s\n", *ramdisk_path);
|
|
||||||
|
|
||||||
*command_line = info->command_line;
|
|
||||||
|
|
||||||
#if defined(USE_CLI) && defined(__LINUX__)
|
#if defined(USE_CLI) && defined(__LINUX__)
|
||||||
printf("command ");
|
printf("command ");
|
||||||
console_cursor_save();
|
console_cursor_save();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "head.h"
|
#include "head.h"
|
||||||
|
|
||||||
extern int read_config(emile_l2_header_t* info, char **kernel_path, char **command_line, char **ramdisk_path);
|
extern int read_config(emile_l2_header_t* info, char **kernel_path, char **command_line, char **ramdisk_path);
|
||||||
|
extern int read_config_modem(char *conf, int *bitrate, int *parity, int *datasize);
|
||||||
|
extern int read_config_printer(char *conf, int *bitrate, int *parity, int *datasize);
|
||||||
|
@ -17,13 +17,9 @@ static int vga_enabled = 0;
|
|||||||
|
|
||||||
void
|
void
|
||||||
console_init(emile_l2_header_t* info)
|
console_init(emile_l2_header_t* info)
|
||||||
{
|
|
||||||
if (info->console_mask & STDOUT_VGA)
|
|
||||||
{
|
{
|
||||||
vga_init();
|
vga_init();
|
||||||
vga_enabled = 1;
|
vga_enabled = 1;
|
||||||
}
|
|
||||||
if ( info->console_mask & (STDOUT_SERIAL0 | STDOUT_SERIAL1) )
|
|
||||||
serial_init(info);
|
serial_init(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
* (c) 2004, 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -14,7 +14,7 @@
|
|||||||
.short 0xA31E
|
.short 0xA31E
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.equ cmdline_length, 256 /* see CL_SIZE in bootinfo.c */
|
.equ paramstring_length, 1024
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
*
|
*
|
||||||
@ -23,41 +23,12 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
_start: bra setup
|
_start: bra setup
|
||||||
_signature: .dc.b 'E','M','0','5'
|
_signature: .dc.b 'E','M','0','6'
|
||||||
|
|
||||||
/* kernel image information */
|
/* EM06 */
|
||||||
|
|
||||||
#ifdef SCSI_SUPPORT
|
_conf_size: .dc.w paramstring_length
|
||||||
_kernel_image_offset: .long scsi_container - _start
|
_configuration: .skip paramstring_length, 0
|
||||||
#else
|
|
||||||
_kernel_image_offset: .long 0
|
|
||||||
#endif
|
|
||||||
_kernel_image_size: .long 0
|
|
||||||
_kernel_size: .long 0
|
|
||||||
|
|
||||||
/* ramdisk image information */
|
|
||||||
|
|
||||||
_ramdisk_offset: .long 0
|
|
||||||
_ramdisk_size: .long 0
|
|
||||||
_command_line: .skip cmdline_length, 0
|
|
||||||
|
|
||||||
/* console management: display, serial modem or printer */
|
|
||||||
|
|
||||||
_console_mask: .long 1
|
|
||||||
_serial0_bitrate: .long 9600
|
|
||||||
_serial0_datasize: .byte 8
|
|
||||||
_serial0_parity: .byte 0
|
|
||||||
_serial0_stopbits: .byte 1
|
|
||||||
_pad0: .byte 0
|
|
||||||
_serial1_bitrate: .long 9600
|
|
||||||
_serial1_datasize: .byte 8
|
|
||||||
_serial1_parity: .byte 0
|
|
||||||
_serial1_stopbits: .byte 1
|
|
||||||
_pad1: .byte 0
|
|
||||||
|
|
||||||
/* Force gestalt for Mystic macintosh */
|
|
||||||
|
|
||||||
_gestaltID: .long 0
|
|
||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
setup:
|
setup:
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
* (c) 2004, 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __HEAD_H__
|
#ifndef __HEAD_H__
|
||||||
#define __HEAD_H__
|
#define __HEAD_H__
|
||||||
|
|
||||||
#define COMMAND_LINE_LENGTH 256
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* WARNING: remember that m68k is big endian, like powerPC.
|
* WARNING: remember that m68k is big endian, like powerPC.
|
||||||
* i386 is little-endian
|
* i386 is little-endian
|
||||||
@ -21,35 +19,30 @@ struct emile_l2_header {
|
|||||||
|
|
||||||
u_int32_t entry;
|
u_int32_t entry;
|
||||||
u_int32_t signature;
|
u_int32_t signature;
|
||||||
|
|
||||||
/* EMO4 addendum: if kernel_image_size == 0,
|
/* EMO4 addendum: if kernel_image_size == 0,
|
||||||
* kernel_image_offset is a pointer to a container
|
* kernel_image_offset is a pointer to a container
|
||||||
* EM05 addendum: if kernel_image_size == kernel_size
|
* EM05 addendum: if kernel_image_size == kernel_size
|
||||||
* kernel is not compressed
|
* kernel is not compressed
|
||||||
|
* EM06 addendum: configuration is now in string configuration
|
||||||
*/
|
*/
|
||||||
u_int32_t kernel_image_offset;
|
|
||||||
u_int32_t kernel_image_size;
|
|
||||||
u_int32_t kernel_size;
|
|
||||||
u_int32_t ramdisk_offset;
|
|
||||||
u_int32_t ramdisk_size;
|
|
||||||
int8_t command_line[COMMAND_LINE_LENGTH];
|
|
||||||
|
|
||||||
/* EM02 */
|
/* EM06 */
|
||||||
|
|
||||||
u_int32_t console_mask;
|
u_int16_t conf_size;
|
||||||
u_int32_t serial0_bitrate;
|
int8_t configuration[0];
|
||||||
int8_t serial0_datasize;
|
|
||||||
int8_t serial0_parity;
|
|
||||||
int8_t serial0_stopbits;
|
|
||||||
int8_t pad0;
|
|
||||||
u_int32_t serial1_bitrate;
|
|
||||||
int8_t serial1_datasize;
|
|
||||||
int8_t serial1_parity;
|
|
||||||
int8_t serial1_stopbits;
|
|
||||||
int8_t pad1;
|
|
||||||
|
|
||||||
/* EM03 */
|
/*
|
||||||
|
* gestaltID <digit>
|
||||||
u_int32_t gestaltID;
|
* modem <bitrate><parity><bits> parity is n/o/e
|
||||||
|
* printer <bitrate><parity><bits>
|
||||||
|
* kernel <protocol>:<unit>/<path> <parameters>
|
||||||
|
* <protocol> is "iso9660", "container", "block" ...
|
||||||
|
* <unit> is "(fd0)", "(sd3)", "(sd0,4)",...
|
||||||
|
* <path> is "boot/vmlinuz-2.2.25", "install/mac/vmlinuz-2.2.25", "59904", "673280,654848",...
|
||||||
|
* initrd <protocol>:<unit>/<path>
|
||||||
|
* configuration <protocol>:<unit>/<path>
|
||||||
|
*/
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
#define EMILE_ID_MASK 0xFFF0
|
#define EMILE_ID_MASK 0xFFF0
|
||||||
@ -63,13 +56,8 @@ struct emile_l2_header {
|
|||||||
#define EMILE_03_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'3')
|
#define EMILE_03_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'3')
|
||||||
#define EMILE_04_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'4')
|
#define EMILE_04_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'4')
|
||||||
#define EMILE_05_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'5')
|
#define EMILE_05_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'5')
|
||||||
|
#define EMILE_06_SIGNATURE (('E'<<24)|('M'<<16)|('0'<<8)|'6')
|
||||||
|
|
||||||
#define EMILE_COMPAT(a,b) ( ( EMILE_ID(a) == EMILE_ID(b) ) && \
|
#define EMILE_COMPAT(a,b) ( ( EMILE_ID(a) == EMILE_ID(b) ) && \
|
||||||
( EMILE_VERSION(a) <= EMILE_VERSION(b) ) )
|
( EMILE_VERSION(a) <= EMILE_VERSION(b) ) )
|
||||||
enum {
|
|
||||||
STDOUT_VGA = 0x00000001,
|
|
||||||
STDOUT_SERIAL0 = 0x00000002,
|
|
||||||
STDOUT_SERIAL1 = 0x00000004,
|
|
||||||
ENABLE_DEBUG = 0x80000000,
|
|
||||||
};
|
|
||||||
#endif /* __HEAD_H__ */
|
#endif /* __HEAD_H__ */
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "head.h"
|
#include "head.h"
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
static short out_refnum0 = -1;
|
static short out_refnum0 = -1;
|
||||||
static short out_refnum1 = -1;
|
static short out_refnum1 = -1;
|
||||||
@ -234,18 +235,24 @@ flush:
|
|||||||
void serial_init(emile_l2_header_t* info)
|
void serial_init(emile_l2_header_t* info)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
int bitrate, parity, datasize, stopbits;
|
||||||
|
|
||||||
if (info->console_mask & STDOUT_SERIAL0) {
|
stopbits = 1;
|
||||||
|
|
||||||
|
res = read_config_modem(info->configuration,
|
||||||
|
&bitrate, &parity, &datasize);
|
||||||
|
if (res != -1)
|
||||||
|
{
|
||||||
res = OpenDriver(c2pstring(".AOut"), &out_refnum0);
|
res = OpenDriver(c2pstring(".AOut"), &out_refnum0);
|
||||||
if (res != noErr) {
|
if (res != noErr) {
|
||||||
printf("Cannot open modem output port (%d)\n", res);
|
printf("Cannot open modem output port (%d)\n", res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = setserial(out_refnum0, info->serial0_bitrate,
|
res = setserial(out_refnum0, bitrate,
|
||||||
info->serial0_datasize,
|
datasize,
|
||||||
info->serial0_parity,
|
parity,
|
||||||
info->serial0_stopbits);
|
stopbits);
|
||||||
if (res != noErr) {
|
if (res != noErr) {
|
||||||
printf("Cannot setup modem output port (%d)\n",
|
printf("Cannot setup modem output port (%d)\n",
|
||||||
res);
|
res);
|
||||||
@ -258,10 +265,10 @@ void serial_init(emile_l2_header_t* info)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = setserial(in_refnum0, info->serial0_bitrate,
|
res = setserial(in_refnum0, bitrate,
|
||||||
info->serial0_datasize,
|
datasize,
|
||||||
info->serial0_parity,
|
parity,
|
||||||
info->serial0_stopbits);
|
stopbits);
|
||||||
if (res != noErr) {
|
if (res != noErr) {
|
||||||
printf("Cannot setup modem input port (%d)\n",
|
printf("Cannot setup modem input port (%d)\n",
|
||||||
res);
|
res);
|
||||||
@ -270,17 +277,19 @@ void serial_init(emile_l2_header_t* info)
|
|||||||
#endif /* USE_CLI */
|
#endif /* USE_CLI */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->console_mask & STDOUT_SERIAL1) {
|
res = read_config_printer(info->configuration,
|
||||||
|
&bitrate, &parity, &datasize);
|
||||||
|
if (res != -1) {
|
||||||
res = OpenDriver(c2pstring(".BOut"), &out_refnum1);
|
res = OpenDriver(c2pstring(".BOut"), &out_refnum1);
|
||||||
if (res != noErr) {
|
if (res != noErr) {
|
||||||
printf("Cannot open printer output port (%d)\n", res);
|
printf("Cannot open printer output port (%d)\n", res);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = setserial(out_refnum1, info->serial1_bitrate,
|
res = setserial(out_refnum1, bitrate,
|
||||||
info->serial1_datasize,
|
datasize,
|
||||||
info->serial1_parity,
|
parity,
|
||||||
info->serial1_stopbits);
|
stopbits);
|
||||||
if (res != noErr) {
|
if (res != noErr) {
|
||||||
printf("Cannot setup printer output port (%d)\n"
|
printf("Cannot setup printer output port (%d)\n"
|
||||||
, res);
|
, res);
|
||||||
@ -293,10 +302,10 @@ void serial_init(emile_l2_header_t* info)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = setserial(in_refnum1, info->serial1_bitrate,
|
res = setserial(in_refnum1, bitrate,
|
||||||
info->serial1_datasize,
|
datasize,
|
||||||
info->serial1_parity,
|
parity,
|
||||||
info->serial1_stopbits);
|
stopbits);
|
||||||
if (res != noErr) {
|
if (res != noErr) {
|
||||||
printf("Cannot setup printer input port (%d)\n"
|
printf("Cannot setup printer input port (%d)\n"
|
||||||
, res);
|
, res);
|
||||||
|
Loading…
Reference in New Issue
Block a user