#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
Go to the source code of this file.
◆ clip_eol()
Definition at line 65 of file ofw_interface.cpp.
67 for(
size_t i = 0;
i < eol_marks.size();
i++ ) {
68 found =
in.find( eol_marks[
i] );
70 in =
in.substr( 0, found );
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Referenced by main().
◆ main()
Definition at line 237 of file ofw_interface.cpp.
242 const char *eol_marks =
"#\r\n";
245 wrappers.
base = 0xe00000;
249 fprintf(
stderr,
"%s [interface.ofw] [ofw.s] [le_stub.c] [le_stub.h]\n",
argv[0] );
267 outcsource.open(
argv[3] );
274 outcheader.open(
argv[4] );
286 out <<
"/* AUTOMATICALLY GENERATED BY ofw_interface */\n" 287 <<
"\t.section .text\n" 289 <<
"\t.globl _start\n" 290 <<
"\t.globl ofw_functions\n" 291 <<
"\t.globl ofw_call_addr\n" 292 <<
"ofw_call_addr:\n" 294 <<
"\n/* Function Wrappers */\n\n" 296 <<
"\n/* Function Names */\n\n" 298 <<
"\n/* Function Call Table for Freeldr */\n\n" 300 <<
"ofw_functions:\n" 304 outcsource <<
"/* AUTOMATICALLY GENERATED BY ofw_interface */\n" 305 <<
"#include \"of.h\"\n" 308 outcheader <<
"/* AUTOMATICALLY GENERATE BY ofw_interface */\n" 309 <<
"#ifndef _OFW_CALLS_H\n" 310 <<
"#define _OFW_CALLS_H\n" 312 <<
"#endif/*_OFW_CALLS_H*/\n";
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
basic_ifstream< char, char_traits< char > > ifstream
std::string clip_eol(std::string in, const std::string &eol_marks)
basic_ofstream< char, char_traits< char > > ofstream
void populate_definition(ofw_wrappers &wrapper, const std::string &line)
static SERVICE_STATUS status
◆ populate_definition()
Definition at line 79 of file ofw_interface.cpp.
81 bool make_function =
true,
method_call =
false, make_stub =
true, comma;
83 std::vector<vartype> argtypes;
84 int args, rets,
i, local_offset, total_stack, userarg_start = 0;
90 if( !
name.size() )
return;
93 nametext =
name.substr(
f+1);
96 if(
name[0] ==
'-' ) {
98 make_function =
false;
100 if(
name[0] ==
'+' ) {
104 if(
name[0] ==
'@' ) {
107 make_function =
false;
110 if( !nametext.size() ) nametext =
name;
115 if( nametext ==
"call-method" )
129 if( !rettype.size() ) rettype =
"void";
131 local_offset = (3 + rets +
args) * 4;
132 total_stack =
round_up(12 + local_offset, 16);
134 function <<
"asm_ofw_" <<
name <<
":\n" 135 <<
"\t/* Reserve stack space */\n" 136 <<
"\tsubi %r1,%r1," << total_stack <<
"\n" 137 <<
"\t/* Store r8, r9, lr */\n" 138 <<
"\tstw %r8," << (local_offset + 0) <<
"(%r1)\n" 139 <<
"\tstw %r9," << (local_offset + 4) <<
"(%r1)\n" 141 <<
"\tstw %r8," << (local_offset + 8) <<
"(%r1)\n" 142 <<
"\t/* Get read name */\n" 143 <<
"\tlis %r8," <<
name <<
"_ofw_name@ha\n" 144 <<
"\taddi %r9,%r8," <<
name <<
"_ofw_name@l\n" 145 <<
"\tstw %r9,0(%r1)\n" 146 <<
"\t/* " <<
args <<
" arguments and " << rets <<
" return */\n" 147 <<
"\tli %r9," <<
args <<
"\n" 148 <<
"\tstw %r9,4(%r1)\n" 149 <<
"\tli %r9," << rets <<
"\n" 150 <<
"\tstw %r9,8(%r1)\n";
152 for(
int i = 0;
i <
args;
i++ )
153 function <<
"\tstw %r" << (
i+3) <<
"," << (4 * (
i + 3)) <<
"(%r1)\n";
155 function <<
"\t/* Load up the call address */\n" 156 <<
"\tlis %r10,ofw_call_addr@ha\n" 157 <<
"\tlwz %r9,ofw_call_addr@l(%r10)\n" 159 <<
"\t/* Set argument */\n" 163 <<
"\tlwz %r3," << (local_offset - 4) <<
"(%r1)\n" 164 <<
"\t/* Restore registers */\n" 165 <<
"\tlwz %r8," << (local_offset + 8) <<
"(%r1)\n" 167 <<
"\tlwz %r9," << (local_offset + 4) <<
"(%r1)\n" 168 <<
"\tlwz %r8," << (local_offset + 0) <<
"(%r1)\n" 169 <<
"\t/* Return */\n" 170 <<
"\taddi %r1,%r1," << total_stack <<
"\n" 174 argtypes.insert(argtypes.begin(),
vartype(
"int"));
175 argtypes.insert(argtypes.begin(),
vartype(
"char*"));
178 le_stub << rettype <<
" ofw_" <<
name <<
"(";
181 for(
i = userarg_start;
i <
args;
i++ ) {
182 if( !argtypes[
i].lit_value.size() ) {
183 if( !comma ) comma =
true;
else le_stub <<
",";
184 le_stub << argtypes[
i].c_type <<
" arg" <<
i;
188 of_call << le_stub.str() <<
";\n";
191 if( rettype !=
"void" )
192 le_stub <<
"\t" << rettype <<
" ret;\n";
195 le_stub <<
"\tchar arg0[" 197 <<
"] = \"" << nametext <<
"\";\n";
201 if( argtypes[
i].lit_value.size() ) {
202 le_stub <<
"\t" << argtypes[
i].c_type <<
" arg" <<
i <<
" = " 203 << argtypes[
i].lit_value <<
";\n";
208 if( rettype !=
"void" ) le_stub <<
"ret = (" << rettype <<
")";
210 le_stub <<
"ofproxy(" <<
213 for(
i = 0;
i < 6;
i++ ) {
214 if(
i <
args ) le_stub <<
",(void *)arg" <<
i;
215 else le_stub <<
",NULL";
220 if( rettype !=
"void" )
221 le_stub <<
"\treturn ret;\n";
225 if( make_function ) wrapper.
functions +=
function.str();
228 wrapper.
of_call += of_call.str();
231 wrapper.
names +=
name +
"_ofw_name:\n\t.asciz \"" + nametext +
"\"\n";
basic_ostringstream< char, char_traits< char >, allocator< char > > ostringstream
int round_up(int x, int factor)
basic_istringstream< char, char_traits< char >, allocator< char > > istringstream
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLuint const GLchar * name
Referenced by main().
◆ round_up()
Definition at line 75 of file ofw_interface.cpp.
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint factor
GLint GLint GLint GLint GLint x
Referenced by populate_definition().
◆ uppercase()
Definition at line 57 of file ofw_interface.cpp.
58 std::vector<char> ucase_work(toucase.size());
59 for(
size_t i = 0;
i < toucase.size();
i++ ) {
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i