@echo off
@rem Revision History
@rem Added preservation of Baseboard Part Number (PBA) which may now be
@rem  programmed during manufacturing (like baseboard serial number)

:restart
if %1.==SKIP. goto domenu
rem Display something to let them know we're working
cls
echo.Please wait...

rem Set initial environment variables
set BDSER=????????
set SESER=????????
call setdenv.bat

chkmode
if errorlevel 1 goto doloop

if %RAMDRIVE%. == . goto noramdrive

rem This supports the readonly configuration

rem Getparts writes its file to the ramdrive
Getparts /f /o%RAMDRIVE%
if errorlevel 1 goto doloop

rem ... and then we run it from the ramdrive
call %RAMDRIVE%setbenv.bat
goto oemchk

:noramdrive

rem Now get part numbers and version numbers
rem from BIOS and Files (into setbenv.bat)

Getparts /f
if errorlevel 1 goto doloop
call setbenv.bat

:oemchk

rem If this disk has been produced using the oemkit then modify it's operation...
if exist oemcust        set _custom=-c

rem If this is the oem support version of the disk, the file "platfbd.bin" must
rem exist to enable oem options.

if exist platfbd.bin	set _oem=-o

rem Internal support option.

if exist psp    	set _psp=-ps

:domenu
rem override environment variables if necessary (usually for prototyping)
if exist checkenv.bat call checkenv.bat

cls
echo.              Update Disk %DSKVER%

if exist protmnu.bat call protmnu.bat

set _both=N

cmpparts -p -d %_custom% %_oem%
if errorlevel 4 goto readback
if errorlevel 3 goto doboth
if errorlevel 2 goto dobb
if errorlevel 1 goto domb

:exit
echo.
echo.Now remove floppy from drive and reboot.
echo.
:doloop
pause >nul
goto restart

:readback
	del bios.rom
	phlash /MFG /EXIT /B=platfbd.bin /RO=bios.rom
	if errorlevel 1 goto error
	goto exit

:doboth
        set _both=Y

:dobb
	if %RAMDRIVE%.==. goto dobblocal

	formbios bb.bin /bd:%BDDPNC%\bbdata.bin /ss:%BDSER% /pb:%BDPN% /of:%RAMDRIVE%bios.tmp %_psp%
	if errorlevel 1 goto error
	if not exist %RAMDRIVE%bios.tmp goto error
        phlash /MFG /EXIT /B=platbb.bin %RAMDRIVE%bios.tmp

	goto dobbonlychk

:dobblocal

	formbios bb.bin /bd:%BDDPNC%\bbdata.bin /ss:%BDSER% /pb:%BDPN% /of:bios.tmp %_psp%
	if errorlevel 1 goto error
	if not exist bios.tmp goto error
        phlash /MFG /EXIT /B=platbb.bin bios.tmp

:dobbonlychk

        if "%_both%"=="N" goto exit

:domb
	if %_custom%. == . goto mainbiosonly
	
	 phlash /MFG /EXIT /B=platoem.bin bios.rom
	 if errorlevel 1 goto error
	 
	goto exit

:mainbiosonly
        phlash /MFG /EXIT /B=platform.bin bios.rom
	goto exit


:error
	echo.Batch file error. Please consult support engineer.

