diff --git a/src/tools/build_isa_pnp_files.c b/src/tools/build_isa_pnp_files.c index 885437c..9d795ee 100755 --- a/src/tools/build_isa_pnp_files.c +++ b/src/tools/build_isa_pnp_files.c @@ -15,9 +15,10 @@ */ // dependancy -#include "..\grayspace-misc\gsdefines.h" -#include "..\sys\include\deviceman\bus_resources.h" -#include "..\sys\include\deviceman\device.h" +#include "../grayspace-misc/gsdefines.h" +#include "../sys/include/deviceman/bus_resources.h" +#include "../sys/include/deviceman/device.h" +#include "make_kernel_string_pool.h" #include "build_isa_pnp_files.h" #include #include @@ -57,6 +58,7 @@ static void FreeAll() { FreeInfos(); + MakeKSP_ResetAll(); } static void AllocateInfos( int numinfos ) @@ -98,7 +100,7 @@ } const static char g_whitespace[] = " \t\n"; -const static char g_classdelimit[] = ";"; +const static char g_classdelimit[] = ";\n"; // returns number of non-white space chars remaining static int RemoveWhiteSpace( char * p_str ) @@ -187,36 +189,7 @@ // fetch everything up until the class name delimiter p_curbuff = strtok( NULL, g_classdelimit ); - if( !p_curbuff ) - { - // no class id, assume generic - - // fetch description - p_curbuff = strtok( NULL, g_whitespace ); - - // copy - if( p_curbuff ) - { - if( strlen( p_curbuff ) <= DEVDESC_MAX_CHARS ) - { - strcpy( p_i->a_desc, p_curbuff ); - } - else - { - printf( "[FillInfo], Warning, device description too long in line: %d, Ignoring\n.", linenum ); - return 0; - } - } - else - { - printf( "[FillInfo], Warning, device description missing in line: %d, Ignoring\n.", linenum ); - return 0; - } - - // fill class as generic - strcpy( p_i->a_class, DEVICE_CLASS_GENERIC_NAME ); - } - else + if( p_curbuff ) { // copy description if( strlen( p_curbuff ) <= DEVDESC_MAX_CHARS ) @@ -225,7 +198,7 @@ } else { - printf( "[FillInfo], Warning, device description too long in line: %d, Ignoring\n.", linenum ); + printf( "[FillInfo], Warning, device description too long in line: %d, Ignoring.\n", linenum ); return 0; } @@ -244,14 +217,16 @@ } else { - printf( "[FillInfo], Warning, invalid device class in line: %d, Ignoring\n.", linenum ); + printf( "[FillInfo], Warning, invalid device class in line: %d, Ignoring.\n", linenum ); return 0; } } else { - printf( "[FillInfo], Warning, missing device class in line: %d, but delimiter is there, Ignoring\n.", linenum ); - return 0; + printf( "[FillInfo], Warning, missing device class in line: %d, Assuming Generic.\n", linenum ); + + // fill class as generic + strcpy( p_i->a_class, DEVICE_CLASS_GENERIC_IDSTR ); } } @@ -259,7 +234,7 @@ return 1; } - printf( "[FillInfo], Warning, invalid PNP-ID in line: %d, Ignoring\n.", linenum ); + printf( "[FillInfo], Warning, invalid PNP-ID in line: %d, Ignoring.\n", linenum ); return 0; } @@ -339,7 +314,7 @@ int i; // open the file - if( !(p_file = fopen( p_path, "rt" )) ) + if( !(p_file = fopen( p_path, "wt" )) ) { printf( "[ReadInConfigFile] Error, cannot open file: %s.\n", p_path ); return 0; @@ -369,19 +344,148 @@ return 0; } -void main( void ) +static int RegisterSubStrings( const char * p_dstpath, + const char * p_srcpath ) { + // HACK: create for now as well + if( Create_SubStringFile( p_dstpath ) ) + { + if( Add_SubStringsFromFile( p_srcpath ) ) + { + if( WriteAndClose_SubStringFile() ) + { + return 1; + } + } + } + + printf( "[WriteDescriptionSubStringsFile] Error, cannot create sub strings file\n" ); + return 0; +} + +static int pnp_str_idx = 0; +static int pnp_num_strs = 0; + +static int RegisterGlobalKStrings( const char * p_dstpath_str, + const char * p_dstpath_substr, + const char * p_srcpath ) +{ + // register the sub strings + if( RegisterSubStrings( p_dstpath_substr, + p_srcpath ) ) + { + // HACK: create for now as well + if( Create_StringFile( p_dstpath_str ) ) + { + if( AppendStringsFromFile( &pnp_str_idx, + &pnp_num_strs, + p_srcpath ) ) + { + if( WriteAndClose_StringFile() ) + { + return 1; + } + } + } + + printf( "[WriteToGlobalKStrings] Error, cannot create strings file\n" ); + } + + return 0; +} + +static int GenerateGlobalKStringsSource( const char * p_strs_path, + const char * p_substrs_path, + const char * p_hdr_path, + const char * p_hdr_name, + const char * p_srccode_path, + const char * p_srccode_name, + const char ** pp_includes, + int numincludes, + const char * p_poolname ) +{ + int ok; + + ok = 0; + + // open the string file + if( Open_StringFile( p_strs_path ) ) + { + // open the sub string file + if( Open_SubStringFile( p_substrs_path ) ) + { + // generate the source code + ok = Create_KStringSourceCode( p_hdr_path, + p_hdr_name, + p_srccode_path, + p_srccode_name, + pp_includes, + numincludes, + p_poolname ); + + // close the sub string file + ok &= Close_SubStringFile(); + } + + // close the string file + ok &= Close_StringFile(); + } + + // return success result + return ok; +} + + +// HACK: +char * ap_includes[] = +{ + "\"../../grayspace-misc/gsdefines.h\"", + "\"../../sys/include/misc/kernel_string_pool.h\"" +}; + +int main( void ) +{ + char buff[1024]; + // first, read in and extract all ISA-PNP devices from configuration file if( !ReadInConfigFile( DEVLIST_FILEPATH_IN ) ) { FreeAll(); - return; + return 0; } // now, generate text file of strings used for device descriptions if( !WriteDescriptionStringsFile( DEVSTRINGS_FILEPATH_TMP ) ) { FreeAll(); - return; + return 0; } + + // add strings to global string files + if( !RegisterGlobalKStrings( KSTRINGS_FILEPATH_TMP, + KSUBSTRINGS_FILEPATH_TMP, + DEVSTRINGS_FILEPATH_TMP ) ) + { + FreeAll(); + return 0; + } + + // generate source files + if( !GenerateGlobalKStringsSource( KSTRINGS_FILEPATH_TMP, + KSUBSTRINGS_FILEPATH_TMP, + DEVLIST_KSTR_HDR_OUT_PATH, + DEVLIST_KSTR_HDR_OUT, + DEVLIST_KSTR_SRC_OUT_PATH, + DEVLIST_KSTR_SRC_OUT, + ap_includes, + sizeof(ap_includes)/sizeof(char *), + DEVLIST_KSTR_POOLNAME ) ) + { + FreeAll(); + return 0; + } + + gets( buff ); + + return 1; } \ No newline at end of file diff --git a/src/tools/build_isa_pnp_files.h b/src/tools/build_isa_pnp_files.h index 4f0794f..c4c39c0 100755 --- a/src/tools/build_isa_pnp_files.h +++ b/src/tools/build_isa_pnp_files.h @@ -21,11 +21,34 @@ // temporary file to hold strings needed to be output to user #define DEVSTRINGS_FILEPATH_TMP "pnpisadevs_strings.txt" +// HACK: acts as global kernel string pool file for now +#define KSTRINGS_FILEPATH_TMP "kstrings.txt" + +// HACK: acts as global kernel sub-string pool file for now +#define KSUBSTRINGS_FILEPATH_TMP "ksubstrings.txt" + +// header file path for string pool to be generated +#define DEVLIST_KSTR_HDR_OUT_PATH "../sys/include/deviceman/devman_stringpool.h" + +// source file path for string pool to be generated +#define DEVLIST_KSTR_SRC_OUT_PATH "../sys/include/deviceman/devman_stringpool.c" + // header file for string pool to be generated -#define DEVLIST_KSTR_POOL_HDR_OUT "isa_pnp_stringpool.h" +#define DEVLIST_KSTR_HDR_OUT "devman_stringpool.h" // source file for string pool to be generated -#define DEVLIST_KSTR_POOL_SRC_OUT "isa_pnp_stringpool.c" +#define DEVLIST_KSTR_SRC_OUT "devman_stringpool.c" + +// global name for string pool +#define DEVLIST_KSTR_POOLNAME "g_kstrp_devman" + +// major header file path for ISAPNP device data-base +// (to contain devices sorted by ID etc.) +#define DEVLIST_HDR_OUT_PATH "../sys/include/deviceman/isa_pnp_devicelist.h" + +// major source file path for ISAPNP device data-base +// (to contain devices sorted by ID etc.) +#define DEVLIST_SRC_OUT_PATH "../sys/include/deviceman/isa_pnp_devicelist.c" // major header file for ISAPNP device data-base // (to contain devices sorted by ID etc.)