Adding upstream version 4.02+dfsg.
[syslinux-debian/hramrach.git] / com32 / cmenu / libmenu / syslnx.c
blob53e2401bb3c79c61e520f44920276cd297f36968
1 /* -*- c -*- ------------------------------------------------------------- *
3 * Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
13 #include <string.h>
14 #include <com32.h>
15 #include "syslnx.h"
17 com32sys_t inreg, outreg; // Global registers for this module
19 char issyslinux(void)
21 REG_EAX(inreg) = 0x00003000;
22 REG_EBX(inreg) = REG_ECX(inreg) = REG_EDX(inreg) = 0xFFFFFFFF;
23 __intcall(0x21, &inreg, &outreg);
24 return (REG_EAX(outreg) == 0x59530000) &&
25 (REG_EBX(outreg) == 0x4c530000) &&
26 (REG_ECX(outreg) == 0x4e490000) && (REG_EDX(outreg) == 0x58550000);
29 void runsyslinuxcmd(const char *cmd)
31 strcpy(__com32.cs_bounce, cmd);
32 REG_AX(inreg) = 0x0003; // Run command
33 REG_BX(inreg) = OFFS(__com32.cs_bounce);
34 REG_ES(inreg) = SEG(__com32.cs_bounce);
35 __intcall(0x22, &inreg, &outreg);
38 void gototxtmode(void)
40 REG_AX(inreg) = 0x0005;
41 __intcall(0x22, &inreg, &outreg);
44 void syslinux_idle(void)
46 REG_AX(inreg) = 0x0013;
47 __intcall(0x22, &inreg, &outreg);
50 unsigned int getversion(char *deriv, unsigned int *numfun)
52 REG_AX(inreg) = 0x0001;
53 __intcall(0x22, &inreg, &outreg);
54 if (deriv)
55 *deriv = REG_DL(outreg);
56 if (numfun)
57 *numfun = REG_AX(outreg);
58 return REG_CX(outreg);
61 void runsyslinuximage(const char *cmd, long ipappend)
63 unsigned int numfun = 0;
64 char *ptr, *cmdline;
66 (void)ipappend; // XXX: Unused?!
68 getversion(NULL, &numfun);
69 // Function 16h not supported Fall back to runcommand
70 if (numfun < 0x16)
71 runsyslinuxcmd(cmd);
72 // Try the Run Kernel Image function
73 // Split command line into
74 strcpy(__com32.cs_bounce, cmd);
75 ptr = __com32.cs_bounce;
76 // serach for first space or end of string
77 while ((*ptr) && (*ptr != ' '))
78 ptr++;
79 if (!*ptr)
80 cmdline = ptr; // no command line
81 else {
82 *ptr++ = '\0'; // terminate kernal name
83 cmdline = ptr + 1;
84 while (*cmdline != ' ')
85 cmdline++; // find first non-space
87 // Now call the interrupt
88 REG_BX(inreg) = OFFS(cmdline);
89 REG_ES(inreg) = SEG(cmdline);
90 REG_SI(inreg) = OFFS(__com32.cs_bounce);
91 REG_DS(inreg) = SEG(__com32.cs_bounce);
92 REG_EDX(inreg) = 0;
94 __intcall(0x22, &inreg, &outreg); // If successful does not return