/* Marquee startup program
* Copyright 2003, Michael Mudge
* COLDC.COM
*/
#include <kernel.h> // Kernel
#include <stdlib.h> // Standard
functions
#include <http.h> // Web
server
#include <bootinfo.h> // Startup function
#include <shell.h> //
Shell-access
#include <netapp.h> // Network
functions
/*
* Default Network Configuration
*/
struct BootInfo Bootrecord = {
"90.0.0.5",
/* Will use this IP if DHCP doesn't work. */
"90.0.0.1",
/* Default Gateway */
"192.5.41.40",
/* Military time server. */
"10.0.0.1",
/* Default File Server - Not currently Used */
"",
/* tftp server -not currently used */
"90.0.0.1",
/* Will use this name server if DHCP doesn't provide
one. */
"",
/* boot file - not used */
0xffffff00UL /* Default
Subnet Mask 255.255.255.0 */
};
// ********** WEB PAGE DESCRIPTION
// HTML pages
extern struct staticpage index_html; //
Main page
extern struct staticpage software_html;
extern struct staticpage board_html;
extern struct staticpage description_html;
extern struct staticpage hardware_html;
extern struct staticpage pictures_html;
extern struct staticpage bootloader_html;
extern struct staticpage bootrecord_html;
extern struct staticpage cgi_c_html;
extern struct staticpage font_data_html;
extern struct staticpage init_marquee_html;
extern struct staticpage main_html;
extern struct staticpage main_c_html;
extern struct staticpage marqueetask_html;
extern struct staticpage netconfig_html;
extern struct staticpage setmessage_html;
extern struct staticpage evalbrd_jpg;
extern struct staticpage explanation_swf;
extern struct staticpage font_gif;
extern struct staticpage schematics_gif;
extern struct staticpage connected_jpg;
extern struct staticpage working_jpg;
extern struct staticpage lasers_jpg;
extern struct staticpage diagram_gif;
// CGIs
extern int setmessage_cgi(int);
// Page that sets the marquee message.
Webpage website[] = {
/* 2 different ways of specifying the
default web page */
{HTTP_PAGE_STATIC, "/", "text/html", &index_html },
{HTTP_PAGE_STATIC, "/index.html",
"text/html", &index_html },
{HTTP_PAGE_STATIC, "/software.html",
"text/html", &software_html },
{HTTP_PAGE_STATIC, "/board.html",
"text/html", &board_html },
{HTTP_PAGE_STATIC, "/description.html",
"text/html", &description_html },
{HTTP_PAGE_STATIC, "/hardware.html",
"text/html", &hardware_html },
{HTTP_PAGE_STATIC, "/pictures.html",
"text/html", &pictures_html },
{HTTP_PAGE_STATIC, "/examples/bootloader.html",
"text/html", &bootloader_html },
{HTTP_PAGE_STATIC, "/examples/bootrecord.html",
"text/html", &bootrecord_html },
{HTTP_PAGE_STATIC, "/examples/cgi_c.html",
"text/html", &cgi_c_html },
{HTTP_PAGE_STATIC, "/examples/font_data.html",
"text/html", &font_data_html },
{HTTP_PAGE_STATIC, "/examples/init_marquee.html",
"text/html", &init_marquee_html },
{HTTP_PAGE_STATIC, "/examples/main.html",
"text/html", &main_html },
{HTTP_PAGE_STATIC, "/examples/main_c.html",
"text/html", &main_c_html },
{HTTP_PAGE_STATIC, "/examples/marqueetask.html",
"text/html", &marqueetask_html },
{HTTP_PAGE_STATIC, "/examples/netconfig.html",
"text/html", &netconfig_html },
{HTTP_PAGE_STATIC, "/examples/setmessage.html",
"text/html", &setmessage_html },
{HTTP_PAGE_STATIC, "/images/evalbrd.jpg",
"image/jpeg", &evalbrd_jpg },
{HTTP_PAGE_STATIC, "/images/explanation.swf",
"application/x-shockwave-flash", &explanation_swf
},
{HTTP_PAGE_STATIC, "/images/font.gif",
"image/gif", &font_gif },
{HTTP_PAGE_STATIC, "/images/schematics.gif",
"image/gif", &schematics_gif },
{HTTP_PAGE_STATIC, "/images/connected.jpg",
"image/jpeg", &connected_jpg },
{HTTP_PAGE_STATIC, "/images/working.jpg",
"image/jpeg", &working_jpg },
{HTTP_PAGE_STATIC, "/images/lasers.jpg",
"image/jpeg", &lasers_jpg },
{HTTP_PAGE_STATIC, "/images/diagram.gif",
"image/gif", &diagram_gif },
// CGI
{HTTP_PAGE_DYNAMIC, "/setmessage.cgi",
"text/html", setmessage_cgi },
{0, NULL, NULL, NULL }
};
// ********** END OF WEB PAGE DESCRIPTION
int main(void) {
// Main program; initializes all vital systems.
/* Load commands that are to be used in
the console. */
extern struct cmdent *allcmds;
extern int nallcmds;
int fd;
// Serial port descriptor.
kprintf("\nServer started.\n");
// Store this in the 'kernel messages' log.
/* This will initialize our telnet
server -- it's completely unprotected
* access, so it should only be used for debugging. */
// telnet_init(&allcmds, nallcmds);
/*
* To initialize a webserver, call http_init(). You need
to pass in a few
* parameters, but the default values shown below
provide a typical webserver.
* The webserver will create several threads to improve
performance. */
http_init(http_defmethods,httpdefheaders,website,80);
/*
* The timed_738 client periodically synchronizes the
eZ80's clock with
* the military time server.
* This timed is based on RFC738, hence the name.
* You can verify if this is working on the console by
typing 'time'.
*/
timed_738_init();
init_marquee(); // Initialize our
marquee software.
// Start up the shell on SERIAL0; the
serial port labeled CONSOLE.
// 57600 bps, 8 data bits, no parity, 2 stop bits, no flow
control
open(SERIAL0, 0,0); //
Initialize serial.
if ((fd=open(TTY, (char *)SERIAL0,0)) == SYSERR) {
// Get serial descriptor.
kprintf("Can't
open tty for SERIAL0\n");
return
SYSERR;
}
kprintf("Starting up a shell on device
%d\n", fd );
shell_init(fd,&allcmds,nallcmds); //
Start a shell on the serial port.
}
/*------------------------------------------------------------------------
* netconfig - set network configuration parms using BOOTP
*------------------------------------------------------------------------
*/
int bootp_tries=5;
void netconfig()
{
// Give it our bootrecord, and "TRUE" for using DHCP.
init_ether(&Bootrecord,TRUE);
return;
}
Web page and source code Copyright 2003, Michael Mudge.