summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/Makefile3
-rw-r--r--mdk-stage1/frontend.h14
-rw-r--r--mdk-stage1/newt-frontend.c23
-rw-r--r--mdk-stage1/stage1.c31
-rw-r--r--mdk-stage1/stage1.h4
-rw-r--r--mdk-stage1/stdio-frontend.c23
6 files changed, 67 insertions, 31 deletions
diff --git a/mdk-stage1/Makefile b/mdk-stage1/Makefile
index deafa52bd..5dbef79af 100644
--- a/mdk-stage1/Makefile
+++ b/mdk-stage1/Makefile
@@ -174,6 +174,9 @@ $(STAGE1OBJS-NETWORK): %-NETWORK.o: %.c .depend
$(INITOBJS): %.o: %.c
$(COMPILE) $(INIT_DEFS) -c $<
+$(FRONTEND_OBJS): %.o: %.c
+ $(COMPILE) $(INCLUDES) -D__FRONTEND_NEED_BACKEND__ -c $<
+
.c.o: .depend
$(COMPILE) $(INCLUDES) $(PCMCIA_DEFS) -c $<
diff --git a/mdk-stage1/frontend.h b/mdk-stage1/frontend.h
index a5950f1da..9658858eb 100644
--- a/mdk-stage1/frontend.h
+++ b/mdk-stage1/frontend.h
@@ -13,16 +13,15 @@
*/
/*
- * Each different frontend must implement all functions defined here
+ * For doc please read doc/documented..frontend.h
*/
-
#ifndef _FRONTEND_H_
#define _FRONTEND_H_
-#include "stage1.h"
+enum return_type { RETURN_OK, RETURN_BACK, RETURN_ERROR };
-void init_frontend(void);
+void init_frontend(char * welcome_msg);
void finish_frontend(void);
void error_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* blocking */
void info_message(char *msg, ...) __attribute__ ((format (printf, 1, 2))); /* blocking */
@@ -38,4 +37,11 @@ enum return_type ask_from_list(char *msg, char ** elems, char ** choice);
enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice);
enum return_type ask_from_entries(char *msg, char ** questions, char *** answers, int entry_size, void (*callback_func)(char ** strings));
+
+#ifdef __FRONTEND_NEED_BACKEND__
+int error_message_backend(void);
+int info_message_backend(void);
+#endif
+
+
#endif
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
index a822227a3..e2b95eb92 100644
--- a/mdk-stage1/newt-frontend.c
+++ b/mdk-stage1/newt-frontend.c
@@ -31,19 +31,16 @@
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
-#include "stage1.h"
-#include "log.h"
#include "newt/newt.h"
#include "frontend.h"
-
-void init_frontend(void)
+void init_frontend(char * welcome_msg)
{
newtInit();
newtCls();
- newtDrawRootText(0, 0, "Welcome to " DISTRIB_NAME " (" VERSION ") " __DATE__ " " __TIME__);
+ newtDrawRootText(0, 0, welcome_msg);
newtPushHelpLine(" <Alt-F1> for here, <Alt-F3> to see the logs, <Alt-F4> for kernel msg");
}
@@ -58,21 +55,25 @@ void finish_frontend(void)
void error_message(char *msg, ...)
{
va_list args;
+#ifdef __FRONTEND_NEED_BACKEND__
+ if (error_message_backend())
+ return;
+#endif
va_start(args, msg);
- va_end(args);
newtWinMessagev("Error", "Ok", msg, args);
- unset_param(MODE_AUTOMATIC);
+ va_end(args);
}
void info_message(char *msg, ...)
{
va_list args;
+#ifdef __FRONTEND_NEED_BACKEND__
+ if (info_message_backend())
+ return;
+#endif
va_start(args, msg);
+ newtWinMessagev("Notice", "Ok", msg, args);
va_end(args);
- if (!IS_AUTOMATIC)
- newtWinMessagev("Notice", "Ok", msg, args);
- else
- vlog_message(msg, args);
}
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 4265138d9..db9a4a15c 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -64,7 +64,8 @@
#endif
-/* globals */
+/************************************************************
+ * globals */
char * method_name;
@@ -76,7 +77,24 @@ void fatal_error(char *msg)
}
-/* spawns a shell on console #2 */
+/************************************************************
+ * backend functs
+ * the principle is to not pollute frontend code with stage1-specific stuff */
+
+int error_message_backend(void)
+{
+ unset_param(MODE_AUTOMATIC);
+ return 0;
+}
+
+int info_message_backend(void)
+{
+ return IS_AUTOMATIC ? 1 : 0;
+}
+
+
+/************************************************************
+ * spawns a shell on console #2 */
static void spawn_shell(void)
{
#ifdef SPAWN_SHELL
@@ -175,6 +193,9 @@ static void spawn_interactive(void)
}
+/************************************************************
+ */
+
static void expert_third_party_modules(void)
{
enum return_type results;
@@ -251,6 +272,10 @@ static void handle_pcmcia(char ** pcmcia_adapter)
#endif
}
+
+/************************************************************
+ */
+
static enum return_type method_select_and_prepare(void)
{
enum return_type results;
@@ -337,7 +362,7 @@ int main(int argc, char **argv, char **env)
handle_env(env);
spawn_shell();
init_modules_insmoding();
- init_frontend();
+ init_frontend("Welcome to " DISTRIB_NAME " (" VERSION ") " __DATE__ " " __TIME__);
if (IS_EXPERT)
expert_third_party_modules();
diff --git a/mdk-stage1/stage1.h b/mdk-stage1/stage1.h
index a6ef9acf4..88445f962 100644
--- a/mdk-stage1/stage1.h
+++ b/mdk-stage1/stage1.h
@@ -28,8 +28,6 @@
/* Some global stuff */
-enum return_type { RETURN_OK, RETURN_BACK, RETURN_ERROR };
-
extern char * method_name;
extern char * interactive_fifo;
@@ -49,4 +47,6 @@ extern char * interactive_fifo;
void fatal_error(char *msg) __attribute__ ((noreturn));
+#define __FRONTEND_NEED_BACKEND__
+
#endif
diff --git a/mdk-stage1/stdio-frontend.c b/mdk-stage1/stdio-frontend.c
index 8ab02f17d..fd3510cf1 100644
--- a/mdk-stage1/stdio-frontend.c
+++ b/mdk-stage1/stdio-frontend.c
@@ -26,16 +26,13 @@
#include <fcntl.h>
#include <sys/ioctl.h>
#include <termios.h>
-#include "stage1.h"
-#include "log.h"
-#include "newt.h"
#include "frontend.h"
-void init_frontend(void)
+void init_frontend(char * welcome_msg)
{
- printf("Welcome to " DISTRIB_NAME " (" VERSION ") " __DATE__ " " __TIME__ "\n");
+ printf(welcome_msg);
}
@@ -176,21 +173,25 @@ static void blocking_msg(char *type, char *fmt, va_list args)
void error_message(char *msg, ...)
{
va_list args;
+#ifdef __FRONTEND_NEED_BACKEND__
+ if (error_message_backend())
+ return;
+#endif
va_start(args, msg);
- va_end(args);
blocking_msg("> Error! ", msg, args);
- unset_param(MODE_AUTOMATIC);
+ va_end(args);
}
void info_message(char *msg, ...)
{
va_list args;
+#ifdef __FRONTEND_NEED_BACKEND__
+ if (info_message_backend())
+ return;
+#endif
va_start(args, msg);
+ blocking_msg("> Notice: ", msg, args);
va_end(args);
- if (!IS_AUTOMATIC)
- blocking_msg("> Notice: ", msg, args);
- else
- vlog_message(msg, args);
}
void wait_message(char *msg, ...)