Recent

Author Topic: How to change the standard stack size in pascal in operating system programing?  (Read 783 times)

TYDQ

  • Jr. Member
  • **
  • Posts: 55
I am developing an UEFI Application with Free Pascal Compiler.As I package all my pascal code to the UEFI bootable iso file(They are packed to generate an dll and then the dll converts to the UEFI Application),I got an accidental exception without any other information shows on the VMWare when testing UEFI Bootable iso.With my second thought and tests on the qemu,I deem that system.pas is the error occurs and the source code is:
Code: Pascal  [Select][+][-]
  1. unit system;
  2. {$MODE FPC}
  3.  
  4. {$MEMORY 1073741824 2147483648}
  5.  
  6. {$POINTERMATH ON}
  7. interface
  8. {$IFDEF CPU32}
  9. const maxheap=16777216*4;
  10.       maxsection=16384;
  11. {$ELSE CPU32}
  12. const maxheap=67108864*4;
  13.       maxsection=65536;
  14. {$ENDIF CPU32}
  15. type
  16.   hresult = LongInt;
  17.   DWord = LongWord;
  18.   Cardinal = LongWord;
  19.   Integer = SmallInt;
  20.   UInt64 = QWord;
  21.   Pbyte=^byte;
  22.   Pchar=^char;
  23.   PWideChar=^WideChar;
  24.   PPWideChar=^PWideChar;
  25.   PWChar=^WideChar;
  26.   PPWChar=^PWChar;
  27.   Pword=^word;
  28.   Pdword=^dword;
  29.   Pqword=^qword;
  30.   PPointer=^Pointer;
  31.   Pboolean=^boolean;
  32.   {$IFDEF CPU32}
  33.   NatUint=dword;
  34.   PNatUint=^dword;
  35.   Natint=integer;
  36.   PNatint=^integer;
  37.   {$ELSE CPU32}
  38.   NatUint=qword;
  39.   PNatUint=^qword;
  40.   Natint=int64;
  41.   PNatint=^int64;
  42.   {$ENDIF CPU32}
  43.   TTypeKind = (tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat, tkSet,
  44.     tkMethod, tkSString, tkLString, tkAString, tkWString, tkVariant, tkArray,
  45.     tkRecord, tkInterface, tkClass, tkObject, tkWChar, tkBool, tkInt64, tkQWord,
  46.     tkDynArray, tkInterfaceRaw, tkProcVar, tkUString, tkUChar, tkHelper, tkFile,
  47.     tkClassRef, tkPointer);
  48.   PTypeKind=^TTypekind;
  49.   jmp_buf = packed record
  50.     rbx, rbp, r12, r13, r14, r15, rsp, rip: QWord;
  51.     {$IFDEF CPU64}
  52.     rsi, rdi: QWord;
  53.     xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15: record
  54.       m1, m2: QWord;
  55.     end;
  56.     mxcsr: LongWord;
  57.     fpucw: word;
  58.     padding: word;
  59.     {$ENDIF CPU64}
  60.   end;
  61.   Pjmp_buf = ^jmp_buf;
  62.   PExceptAddr = ^TExceptAddr;
  63.   TExceptAddr = record
  64.     buf: Pjmp_buf;
  65.     next: PExceptAddr;
  66.     {$IFDEF CPU16}
  67.     frametype: SmallInt;
  68.     {$ELSE CPU16}
  69.     frametype: LongInt;
  70.     {$ENDIF CPU16}
  71.   end;
  72.   PGuid = ^TGuid;
  73.   TGuid = packed record
  74.     case Integer of
  75.     1:
  76.      (Data1: DWord;
  77.       Data2: word;
  78.       Data3: word;
  79.       Data4: array [0 .. 7] of byte;
  80.     );
  81.     2:
  82.      (D1: DWord;
  83.       D2: word;
  84.       D3: word;
  85.       D4: array [0 .. 7] of byte;
  86.     );
  87.     3:
  88.     ( { uuid fields according to RFC4122 }
  89.       time_low: DWord; // The low field of the timestamp
  90.       time_mid: word; // The middle field of the timestamp
  91.       time_hi_and_version: word;
  92.       // The high field of the timestamp multiplexed with the version number
  93.       clock_seq_hi_and_reserved: byte;
  94.       // The high field of the clock sequence multiplexed with the variant
  95.       clock_seq_low: byte; // The low field of the clock sequence
  96.       node: array [0 .. 5] of byte; // The spatially unique node identifier
  97.     );
  98.   end;
  99.   systemheap=record
  100.            heapcontent:array[1..maxheap] of byte;
  101.            heapsection:array[1..maxsection,1..2] of natuint;
  102.            heapcount,heaprest:natuint;
  103.            end;
  104. procedure fpc_initialize(data,info:Pointer);compilerproc;
  105. procedure fpc_finalize(data,Info:Pointer);compilerproc;      
  106. procedure fpc_specific_handler;compilerproc;
  107. function sys_getmem(size:natuint):Pointer;compilerproc;
  108. procedure sys_freemem(var p:pointer);compilerproc;
  109. function sys_allocmem(size:natuint):Pointer;compilerproc;
  110. procedure sys_reallocmem(var p:Pointer;size:natuint);compilerproc;
  111. procedure sys_move(const source;var dest;count:natuint);compilerproc;
  112. function getmem(size:natuint):Pointer;
  113. procedure freemem(var p:pointer);
  114. function allocmem(size:natuint):Pointer;
  115. procedure reallocmem(var p:Pointer;size:natuint);
  116. procedure move(const source;var dest;count:natuint);
  117. var compheap,sysheap:systemheap;
  118. implementation
  119. procedure fpc_initialize(Data,Info:Pointer);compilerproc;[public,alias:'FPC_INITIALIZE'];
  120. begin
  121. end;
  122. procedure fpc_finalize(Data,Info:Pointer);compilerproc;[public,alias:'FPC_FINALIZE'];
  123. begin
  124. end;
  125. procedure fpc_specific_handler;compilerproc;[public,alias:'__FPC_specific_handler'];
  126. begin
  127. end;
  128. procedure compheap_delete_item(p:pointer);
  129. var i,j,len:natuint;
  130. begin
  131.  for i:=1 to compheap.heapcount do
  132.   begin
  133.    if(natuint(p)>=compheap.heapsection[i,1]) and (natuint(p)<=compheap.heapsection[i,2]) then break;
  134.   end;
  135.  if(i>compheap.heapcount) then exit;
  136.  len:=compheap.heapsection[i,2]-compheap.heapsection[i,1];
  137.  for j:=i+1 to compheap.heapcount do
  138.   begin
  139.    compheap.heapsection[j-1,1]:=compheap.heapsection[j,1]-len;
  140.    compheap.heapsection[j-1,2]:=compheap.heapsection[j,2]-len;
  141.   end;
  142.  compheap.heapsection[compheap.heapcount,1]:=0;
  143.  compheap.heapsection[compheap.heapcount,2]:=0;
  144.  dec(compheap.heapcount); inc(compheap.heaprest,len);
  145. end;
  146. function sys_getmem(size:natuint):Pointer;compilerproc;[public,alias:'FPC_GETMEM'];
  147. var i,istart:natuint;
  148. begin
  149.  if(compheap.heapcount>=maxsection) then sys_getmem:=nil;
  150.  if(compheap.heaprest<size) then sys_getmem:=nil;
  151.  if(size=0) then sys_getmem:=nil;
  152.  if(compheap.heapcount>0) then istart:=compheap.heapsection[compheap.heapcount,2]+1 else istart:=Natuint(@compheap.heapcontent);
  153.  inc(compheap.heapcount);
  154.  compheap.heapsection[compheap.heapcount,1]:=istart;
  155.  compheap.heapsection[compheap.heapcount,2]:=istart+size-1;
  156.  for i:=1 to size do
  157.   begin
  158.    compheap.heapcontent[istart+i-1]:=0;
  159.   end;
  160.  dec(compheap.heaprest,size);
  161.  sys_getmem:=Pointer(compheap.heapsection[compheap.heapcount,1]);
  162. end;
  163. procedure sys_freemem(var p:pointer);compilerproc;[public,alias:'FPC_FREEMEM'];
  164. begin
  165.  compheap_delete_item(p); p:=nil;
  166. end;
  167. function sys_allocmem(size:natuint):Pointer;compilerproc;[public,alias:'FPC_ALLOCMEM'];
  168. var i,istart:natuint;
  169. begin
  170.  if(compheap.heapcount>=maxsection) then sys_allocmem:=nil;
  171.  if(compheap.heaprest<size) then sys_allocmem:=nil;
  172.  if(size=0) then sys_allocmem:=nil;
  173.  if(compheap.heapcount>0) then istart:=compheap.heapsection[compheap.heapcount,2]+1 else istart:=NatUint(@compheap.heapcontent);
  174.  inc(compheap.heapcount);
  175.  compheap.heapsection[compheap.heapcount,1]:=istart;
  176.  compheap.heapsection[compheap.heapcount,2]:=istart+size-1;
  177.  for i:=1 to size do
  178.   begin
  179.    compheap.heapcontent[istart+i-1]:=0;
  180.   end;
  181.  dec(compheap.heaprest,size);
  182.  sys_allocmem:=Pointer(compheap.heapsection[compheap.heapcount,1]);
  183. end;
  184. procedure sys_reallocmem(var p:Pointer;size:natuint);compilerproc;[public,alias:'FPC_REALLOCMEM'];
  185. var i,istart,len:Natuint;
  186.     newp:Pointer;
  187.     p1,p2:Pchar;
  188. begin
  189.  if(compheap.heapcount>=maxsection) then exit;
  190.  if(compheap.heaprest<size) then exit;
  191.  if(size=0) then exit;
  192.  if(compheap.heapcount>0) then istart:=compheap.heapsection[compheap.heapcount,2]+1 else istart:=Natuint(@compheap.heapcontent);
  193.  inc(compheap.heapcount);
  194.  compheap.heapsection[compheap.heapcount,1]:=istart;
  195.  compheap.heapsection[compheap.heapcount,2]:=istart+size-1;
  196.  for i:=1 to size do
  197.   begin
  198.    compheap.heapcontent[istart+i-1]:=0;
  199.   end;
  200.  dec(compheap.heaprest,size);
  201.  newp:=Pointer(compheap.heapsection[compheap.heapcount,1]);
  202.  for i:=1 to compheap.heapcount do
  203.   begin
  204.    if(NatUint(p)>=compheap.heapsection[i,1]) and (NatUint(p)<=compheap.heapsection[i,2]) then break;
  205.   end;
  206.  len:=NatUint(p)-compheap.heapsection[i,1];
  207.  p1:=@p^; p2:=@newp^;
  208.  for i:=1 to compheap.heapsection[i,2]-compheap.heapsection[i,1]+1 do p2^:=p1^;
  209.  compheap_delete_item(p); p:=newp+len;
  210. end;
  211. procedure sys_move(const source;var dest;count:natuint);compilerproc;[public,alias:'FPC_MOVE'];
  212. var p1,p2:Pchar;
  213.     i:natuint;
  214. begin
  215.  p1:=@source; p2:=@dest;
  216.  for i:=1 to count do p2^:=p1^;
  217. end;
  218. function fpc_copy_proc(src,dest,typeinfo:Pointer):natint;compilerproc;[public,alias:'fpc_copy_proc'];
  219. var address1,address2:Pbyte;
  220.     i:natuint;
  221. begin
  222.  address1:=src; address2:=dest;
  223.  for i:=1 to sizeof(src^) do
  224.   begin
  225.    (address2+i-1)^:=(address1+i-1)^;
  226.   end;
  227. end;
  228. procedure sysheap_delete_item(p:pointer);
  229. var i,j,len:natuint;
  230. begin
  231.  for i:=1 to sysheap.heapcount do
  232.   begin
  233.    if(natuint(p)>=sysheap.heapsection[i,1]) and (natuint(p)<=sysheap.heapsection[i,2]) then break;
  234.   end;
  235.  if(i>sysheap.heapcount) then exit;
  236.  len:=sysheap.heapsection[i,2]- sysheap.heapsection[i,1];
  237.  for j:=i+1 to sysheap.heapcount do
  238.   begin
  239.     sysheap.heapsection[j-1,1]:= sysheap.heapsection[j,1]-len;
  240.     sysheap.heapsection[j-1,2]:= sysheap.heapsection[j,2]-len;
  241.   end;
  242.   sysheap.heapsection[sysheap.heapcount,1]:=0;
  243.   sysheap.heapsection[sysheap.heapcount,2]:=0;
  244.  dec(sysheap.heapcount); inc(sysheap.heaprest,len);
  245. end;
  246. function getmem(size:natuint):Pointer;[public,alias:'getmem'];
  247. var i,istart:natuint;
  248. begin
  249.  if(sysheap.heapcount>=maxsection) then getmem:=nil;
  250.  if(sysheap.heaprest<size) then getmem:=nil;
  251.  if(size=0) then getmem:=nil;
  252.  if(sysheap.heapcount>0) then istart:=sysheap.heapsection[sysheap.heapcount,2]+1 else istart:=Natuint(@sysheap.heapcontent);
  253.  inc(sysheap.heapcount);
  254.  sysheap.heapsection[sysheap.heapcount,1]:=istart;
  255.  sysheap.heapsection[sysheap.heapcount,2]:=istart+size-1;
  256.  for i:=1 to size do
  257.   begin
  258.    sysheap.heapcontent[istart+i-1]:=0;
  259.   end;
  260.  dec(sysheap.heaprest,size);
  261.  getmem:=Pointer(sysheap.heapsection[sysheap.heapcount,1]);
  262. end;
  263. procedure freemem(var p:pointer);[public,alias:'freemem'];
  264. begin
  265.  sysheap_delete_item(p); p:=nil;
  266. end;
  267. function allocmem(size:natuint):Pointer;[public,alias:'allocmem'];
  268. var i,istart:natuint;
  269. begin
  270.  if(sysheap.heapcount>=maxsection) then allocmem:=nil;
  271.  if(sysheap.heaprest<size) then allocmem:=nil;
  272.  if(size=0) then allocmem:=nil;
  273.  if(sysheap.heapcount>0) then istart:=sysheap.heapsection[sysheap.heapcount,2]+1 else istart:=NatUint(@sysheap.heapcontent);
  274.  inc(sysheap.heapcount);
  275.  sysheap.heapsection[sysheap.heapcount,1]:=istart;
  276.  sysheap.heapsection[sysheap.heapcount,2]:=istart+size-1;
  277.  for i:=1 to size do
  278.   begin
  279.    sysheap.heapcontent[istart+i-1]:=0;
  280.   end;
  281.  dec(sysheap.heaprest,size);
  282.  allocmem:=Pointer(sysheap.heapsection[sysheap.heapcount,1]);
  283. end;
  284. procedure reallocmem(var p:Pointer;size:natuint);[public,alias:'reallocmem'];
  285. var i,len:Natuint;
  286.     newp:Pointer;
  287. begin
  288.  newp:=getmem(size);
  289.  for i:=1 to sysheap.heapcount do
  290.   begin
  291.    if(NatUint(p)>=sysheap.heapsection[i,1]) and (NatUint(p)<=sysheap.heapsection[i,2]) then break;
  292.   end;
  293.  len:=NatUint(p)-compheap.heapsection[i,1];
  294.  move(p^,newp^,sysheap.heapsection[i,2]-sysheap.heapsection[i,1]+1);
  295.  sysheap_delete_item(p); p:=newp+len;
  296. end;
  297. procedure move(const source;var dest;count:natuint);[public,alias:'move'];
  298. var p1,p2:Pchar;
  299.     i:natuint;
  300. begin
  301.  p1:=@source; p2:=@dest;
  302.  for i:=1 to count do p2^:=p1^;
  303. end;
  304. function strlen(str:Pchar):natuint;[public,alias:'strlen'];
  305. var res:natuint;
  306. begin
  307.  res:=0;
  308.  while(str^<>#0) do
  309.   begin
  310.    inc(str); inc(res);
  311.   end;
  312.  dec(str,res);
  313.  strlen:=res;
  314. end;
  315. function wstrlen(str:PWideChar):natuint;[public,alias:'wstrlen'];
  316. var res:natuint;
  317. begin
  318.  res:=0;
  319.  while(str^<>#0) do
  320.   begin
  321.    inc(str); inc(res);
  322.   end;
  323.  dec(str,res);
  324.  wstrlen:=res;
  325. end;
  326. function strcmp(str1,str2:Pchar):natint;[public,alias:'strcmp'];
  327. var i:natint;
  328. begin
  329.  i:=0;
  330.  while((str1+i)^=(str2+i)^) and ((str1+i)^<>#0) and ((str2+i)^<>#0) do inc(i);
  331.  if((str1+i)^>(str2+i)^) then strcmp:=1
  332.  else if((str1+i)^<(str2+i)^) then strcmp:=-1
  333.  else strcmp:=0;
  334. end;
  335. function Wstrcmp(str1,str2:PwideChar):natint;[public,alias:'Wstrcmp'];
  336. var i:natint;
  337. begin
  338.  i:=0;
  339.  while((str1+i)^=(str2+i)^) and ((str1+i)^<>#0) and ((str2+i)^<>#0) do inc(i);
  340.  if((str1+i)^>(str2+i)^) then Wstrcmp:=1
  341.  else if((str1+i)^<(str2+i)^) then Wstrcmp:=-1
  342.  else Wstrcmp:=0;
  343. end;
  344. var i:dword;
  345. begin
  346.  compheap.heapcount:=0; compheap.heaprest:=maxheap;
  347.  sysheap.heapcount:=0; sysheap.heaprest:=maxheap;
  348. end.
My other Codes are:
uefi.pas:(Too large to show you in the forum due to maximum allowed length 20000 characters)
uefimain.pas:
Code: Pascal  [Select][+][-]
  1. unit uefimain;
  2. interface
  3.  
  4. uses uefi;
  5.  
  6. function efi_main(ImageHandle:efi_handle;systemtable:Pefi_system_table):efi_status;cdecl;
  7.  
  8. implementation
  9.  
  10. function efi_main(ImageHandle:efi_handle;systemtable:Pefi_system_table):efi_status;cdecl;[public,alias:'efi_main'];
  11. var mystr:PWideChar;
  12.     i,realsize:natuint;
  13.     status:efi_status;
  14.     efi_interface_list:efi_disk_interface_list;
  15.     efi_block_list:efi_block_interface_list;
  16.     myhandle:efi_handle;
  17.     gpe:efi_gpt_partition_array;
  18.     mbrhead:master_boot_record;
  19.     gptheader:efi_gpt_header;
  20.     gptarray:efi_gpt_entry_array;
  21.     efsl:efi_file_system_list;
  22.     efp:Pefi_file_protocol;
  23.     efsi:efi_file_system_info;
  24. begin
  25.  gpe.array_content:=allocmem(4*sizeof(efi_gpt_partition_array_content));
  26.  gpe.array_count:=2;
  27.  efi_console_set_global_colour(Systemtable,efi_bck_black,efi_lightgrey);
  28.  efi_console_clear_screen(systemtable);
  29.  efi_console_get_max_row_and_max_column(systemtable,true);
  30.  efi_console_enable_mouse(systemtable);
  31.  efi_console_enable_mouse_blink(systemtable,true,500);
  32.  efi_interface_list:=efi_detect_disk(systemtable);
  33.  efi_block_list:=efi_detect_block(systemtable);
  34.  for i:=1 to efi_block_list.block_count do
  35.   begin
  36.    efi_console_output_string(systemtable,UintToPWChar(((efi_block_list.block_interface+i-1)^)^.Media^.MediaId));
  37.    efi_console_output_string(systemtable,#13#10);
  38.    efi_console_output_string(systemtable,UintToPWChar(efi_get_disk_size(efi_block_list,i)));
  39.    efi_console_output_string(systemtable,#13#10);
  40.   end;
  41.   gpe.array_content^.startlba:=0;
  42.   gpe.array_content^.endlba:=256*1024*2-1;
  43.   (gpe.array_content+1)^.startlba:=256*1024*2;
  44.   (gpe.array_content+1)^.endlba:=((efi_block_list.block_interface)^)^.Media^.LastBlock-gpe.array_count;
  45.   //efi_clear_disk(efi_interface_list,efi_block_list,1);
  46.   efi_zone_disk(efi_interface_list,efi_block_list,1,gpe);
  47.   mbrhead:=efi_read_disk_format_mbr(efi_interface_list,efi_block_list,1);
  48.   efi_console_output_string(systemtable,'MBR Head:'+#13#10);
  49.   efi_console_output_string(systemtable,DataToHex(Pointer(@mbrhead),sizeof(master_boot_record)));
  50.   efi_console_output_string(systemtable,#13#10);
  51.   gptheader:=efi_read_disk_format_gpt(efi_interface_list,efi_block_list,1);
  52.   efi_console_output_string(systemtable,'GPT Header:'+#13#10);
  53.   efi_console_output_string(systemtable,DataToHex(Pointer(@gptheader),sizeof(efi_gpt_header)));
  54.   efi_console_output_string(systemtable,#13#10);
  55.   gptarray:=efi_read_disk_gpt_entry_array(efi_interface_list,efi_block_list,1);
  56.   efi_console_output_string(systemtable,'GPT Entries Number:');
  57.   efi_console_output_string(systemtable,UintToPWChar(gptarray.entry_count));
  58.   efi_console_output_string(systemtable,#13#10);
  59.   if(gptarray.entry_count>0) then efi_console_output_string(systemtable,'GPT Entries:'+#13#10);
  60.   for i:=1 to gptarray.entry_count do
  61.    begin
  62.     efi_console_output_string(systemtable,DataToHex(gptarray.entry_content+i-1,sizeof(efi_partition_entry)));
  63.     efi_console_output_string(systemtable,#13#10);
  64.    end;
  65.  efsl:=efi_list_all_file_system(systemtable);
  66.  efi_console_output_string(systemtable,UintToPWChar(efsl.file_system_count));
  67.  efi_console_output_string(systemtable,#13#10);
  68.  for i:=1 to efsl.file_system_count do
  69.   begin
  70.    realsize:=sizeof(efi_file_system_info);
  71.    efi_console_output_string(systemtable,UintToPWChar(Qword(realsize)));
  72.    efi_console_output_string(systemtable,#13#10);
  73.    status:=((efsl.file_system_content+i-1)^)^.OpenVolume((efsl.file_system_content+i-1)^,efp);
  74.    if(status<>efi_success) then
  75.     begin
  76.      efi_console_output_string(systemtable,'ERROR1!'+#13#10);
  77.      break;
  78.     end;
  79.    status:=efp^.GetInfo(efp,@efi_file_system_info_id,realsize,efsi);
  80.    if(status<>efi_success) then
  81.     begin
  82.      efi_console_output_string(systemtable,'ERROR2!'+#13#10);
  83.      break;
  84.     end;
  85.    efi_console_output_string(systemtable,UintToPWChar(efsi.size));
  86.    efi_console_output_string(systemtable,' ');
  87.    efi_console_output_string(systemtable,UintToPWChar(efsi.volumesize));
  88.    efi_console_output_string(systemtable,' ');
  89.    efi_console_output_string(systemtable,UintToPWChar(efsi.FreeSpace));
  90.    efi_console_output_string(systemtable,' ');
  91.    efi_console_output_string(systemtable,UintToPWChar(efsi.BlockSize));
  92.    efi_console_output_string(systemtable,' ');
  93.    efi_console_output_string(systemtable,@efsi.VolumeLabel);
  94.    efi_console_output_string(systemtable,' ');
  95.    efi_console_output_string(systemtable,#13#10);
  96.    efp^.Close(efp);
  97.   end;
  98.  efi_console_output_string(systemtable,'Hello UEFI!'+#13#10);
  99.  efi_console_read_string(systemtable,mystr);
  100.  efi_console_output_string(systemtable,mystr);
  101.  efi_install_cdrom_to_disk(systemtable,1,1);
  102.  while(True) do;
  103.  efi_main:=efi_success;
  104. end;
  105.  
  106. end.
build.sh:
Code: Bash  [Select][+][-]
  1. fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Ct -Px86_64 -Rintel -Twin64 -Cg uefimain.pas
  2.         x86_64-w64-mingw32-ld --gc-sections -shared -Bsymbolic -Wl,--stack,1073741824 -nostdlib -oformat pei-x86-64 uefimain.o uefi.o system.o -e efi_main -o main.dll
  3.         objcopy -I pei-x86-64 -O efi-app-x86_64 main.dll bootx64.efi
  4.         dd if=/dev/zero of=fat.img bs=512 count=131072
  5.         /usr/sbin/mkfs.vfat -F 32 fat.img
  6.         mmd -i fat.img ::/EFI
  7.         mmd -i fat.img ::/EFI/BOOT
  8.         mcopy -i fat.img bootx64.efi ::/EFI/BOOT
  9.         mkdir iso
  10.         cp fat.img iso
  11.         xorriso -as mkisofs -R -f -e fat.img -no-emul-boot -o cdimage.iso iso
  12.         qemu-system-x86_64 -bios OVMF.fd -m 4096 -net none -cdrom cdimage.iso --no-reboot
  13.         rm -rf iso
  14.         rm -rf *.ppu
  15.         rm -rf fat.img
(The completed code is on my github.The link is:https://github.com/TYDQSoft/UEFIPascalOS)
Due to these codes' array are too large,it is a must-do to expand the stack size otherwise my code cannot execute on VMWare.So,Does anyone have a method to solve my problem?
« Last Edit: April 29, 2024, 11:08:58 am by TYDQ »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Code: Pascal  [Select][+][-]
  1. {$MEMORY 1073741824 2147483648}
By looking at documentation you simply forgot to place a commata between the sizes.
Quote
{$M StackSize,HeapSize}
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

TYDQ

  • Jr. Member
  • **
  • Posts: 55
Code: Pascal  [Select][+][-]
  1. {$MEMORY 1073741824 2147483648}
By looking at documentation you simply forgot to place a commata between the sizes.
Quote
{$M StackSize,HeapSize}
I tried this,but the program still crashes on the VMWare,is the problem of VMWare or my pascal code itself?
« Last Edit: April 29, 2024, 11:19:50 am by TYDQ »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Code: Pascal  [Select][+][-]
  1. {$MEMORY 1073741824 2147483648}
By looking at documentation you simply forgot to place a commata between the sizes.
Quote
{$M StackSize,HeapSize}
// here you wrote something different while I opened Lazarus to make a screen shot :D
The only other way that I am aware about would be to set it in Project Options as shown in attachment.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

TYDQ

  • Jr. Member
  • **
  • Posts: 55
Code: Pascal  [Select][+][-]
  1. {$MEMORY 1073741824 2147483648}
By looking at documentation you simply forgot to place a commata between the sizes.
Quote
{$M StackSize,HeapSize}
// here you wrote something different while I opened Lazarus to make a screen shot :D
The only other way that I am aware about would be to set it in Project Options as shown in attachment.
Are you kidding me?Can lazarus develop UEFI applications?UEFI application are executed not in operating system but UEFI-based bare machine!So I use fpc only to develop an UEFI Application.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
I tried this,but the program still crashes on the VMWare,is the problem of VMWare or my pascal code itself?
I am unsure how far a virtual machine does support UEFI so I would test on a real machine.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Are you kidding me?Can lazarus develop UEFI applications?UEFI application are executed not in operating system but UEFI-based bare machine!So I use fpc only to develop an UEFI Application.
Lazarus is an IDE to have more comfort while coding and when you compile its using FPC so I am not kidding and wishing you a nice day.
//edit and the answer to your "can" question is yes.
« Last Edit: April 29, 2024, 11:52:27 am by KodeZwerg »
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

TYDQ

  • Jr. Member
  • **
  • Posts: 55
I tried this,but the program still crashes on the VMWare,is the problem of VMWare or my pascal code itself?
I am unsure how far a virtual machine does support UEFI so I would test on a real machine.
If I deleted the *4 on maxheap,the program can execute while if I maintain the *4 on maxheap it cannot execute.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11580
  • FPC developer.
I tried this,but the program still crashes on the VMWare,is the problem of VMWare or my pascal code itself?

Passing the initial stacksize is probably OS specific. So the question is that if UEFI really supports setting stack size, and if the FPC parameter reaches it somehow (via binary format, a setting for startup code or whatever)

TYDQ

  • Jr. Member
  • **
  • Posts: 55
I tried this,but the program still crashes on the VMWare,is the problem of VMWare or my pascal code itself?

Passing the initial stacksize is probably OS specific. So the question is that if UEFI really supports setting stack size, and if the FPC parameter reaches it somehow (via binary format, a setting for startup code or whatever)
However,UEFI specification don't tell me that,so I must try it myself.I  think UEFI really supports setting stack size because on QEMU it is not throw a errorous information.

 

TinyPortal © 2005-2018