Jump to content

C++ proposition


Jief_Machak
 Share

823 posts in this topic

Recommended Posts

14 hours ago, Jief_Machak said:

Looking at the display bug, I realise that DBG("%s\n", string) with string being a CHAR16* doesn't work. I traced into the edk sources and it's just can't. AsciiVSPrint output in utf8 and there is no conversion.

To workaround that, I've committed a XString (no W). To convert a Lstring to utf8, Just do XString(Lstring).c ( .c is to get a pointer to give to DBG or other).

 

I see a glitch with boot-args in Options menu. It is probably caused by

    AsciiSPrint(gSettings.BootArgs, 255, "%s ", InputItems.SValue);

 

Link to comment
Share on other sites

Just now, Slice said:

I see a glitch with boot-args in Options menu. It is probably caused by

    AsciiSPrint(gSettings.BootArgs, 255, "%s ", InputItems.SValue);

 

Yes, I've noticed Ascii...Print cannot convert UTF16 to UTF8. Quick fix "AsciiSPrint(gSettings.BootArgs, 255, "%a ", XString(InputItems.SValue).c);"

Link to comment
Share on other sites

43 minutes ago, Jief_Machak said:

Yes, I've noticed Ascii...Print cannot convert UTF16 to UTF8. Quick fix "AsciiSPrint(gSettings.BootArgs, 255, "%a ", XString(InputItems.SValue).c);"

 

How could this be true? The EDK2 functions have distinct %s and %a and it worked previously when used in c, the line is exactly the same, the only thing that changed was the string type...? Also it converts to ASCII, not UTF-8... Which is what is needed there for the boot arguments. The UEFI specification only uses ASCII and UCS-2. I see some problems with code is more likely what is the issue.... Like why not just get the c string from the value, how are you ensuring it is coerced to the correct type when passed? Why are you using a public variable for your string storage? I can create this string, set the c member = nullptr and then you have memory leak, or I could possibly exploit your code to inject my own code...

Link to comment
Share on other sites

I maybe be wrong, but for what I saw, Ascii...Print function output Ascii, we agree. But %s format in Ascii...Print expect a Ascii string, not an UCS-2, like unicode...print function.

We didn't touch anything in Print function. I may compiled on old version to check.

Link to comment
Share on other sites

New hang with latest commit happens at the line

50:544  0:047  === [ StartLoader ] =======================================
52:480  1:936  Finally: ExternalClock=212MHz BusSpeed=211353kHz CPUFreq=3593MHz PIS: hw.busfrequency=848000000Hz
Those values wrong.

  DBG("Finally: ExternalClock=%ldMHz BusSpeed=%ldkHz CPUFreq=%ldMHz",
  				DivU64x32(gCPUStructure.ExternalClock + kilo - 1, kilo),
  				DivU64x32(gCPUStructure.FSBFrequency + kilo - 1, kilo),
          gCPUStructure.MaxSpeed);
  if (gSettings.QPI) {
    DBG(" QPI: hw.busfrequency=%ldHz\n", MultU64x32(gSettings.QPI, Mega));
  } else {
    // to match the value of hw.busfrequency in the terminal
    DBG(" PIS: hw.busfrequency=%ldHz\n", MultU64x32(LShiftU64(DivU64x32(gCPUStructure.ExternalClock + kilo - 1, kilo), 2), Mega));
  }
  

We see no next DBG. It means hang at DivU64x32() or in the next MultU64x32()

Link to comment
Share on other sites

Hang at deleteFont. It is my mistake.

9 minutes ago, Jief_Machak said:

Have you tried my gdb_launch ? So much easier to catch a crash...

It is too hard to install. Anyway I am at windows now.

Link to comment
Share on other sites

4 minutes ago, Jief_Machak said:

What about NSVGfont become a class and NSVGfontChain become an XArrayObj ? :):) Memory problem will solve themselves...

Yes, but the whole nanosvg should be rewritten. Not now.

Link to comment
Share on other sites

1 hour ago, Slice said:

New hang with latest commit happens at the line

50:544  0:047  === [ StartLoader ] =======================================
52:480  1:936  Finally: ExternalClock=212MHz BusSpeed=211353kHz CPUFreq=3593MHz PIS: hw.busfrequency=848000000Hz
Those values wrong.

 

55 minutes ago, Jief_Machak said:

No crash here. I got :

 

171:773  0:001  === [ StartLoader ] =======================================
171:779  0:005  Finally: ExternalClock=703MHz BusSpeed=702010kHz CPUFreq=2808MHz PIS: hw.busfrequency=2812000000Hz

 

Looks like something is wrong there though as that can't be correct unless you have some crazy machine that has 703MHz clock....

Link to comment
Share on other sites

At home I used QEMU 2 in macOS with SeaBios. At work I use QEMU 3 in Windows with my OVMF.

Both reported strange frequencies, strange CPU multipliers.

There is a setting in Clover "QEMU=true" but I can't change the value reported by MSR 0x198 - max CPU multiplier.

Link to comment
Share on other sites

2 hours ago, Jief_Machak said:

I maybe be wrong, but for what I saw, Ascii...Print function output Ascii, we agree. But %s format in Ascii...Print expect a Ascii string, not an UCS-2, like unicode...print function.

We didn't touch anything in Print function. I may compiled on old version to check.

Print argument semantics are of course unaffected by the family of functions used. "%a" is ASCII, "%s" is UCS-2, always. It makes no sense to make argument interpretation different based on the destination type anyway.

Link to comment
Share on other sites

Noticing we were defining memcpy, memset, strcpy etc. in different files and sometimes headers, having some clash with "already defined" or "undefined", I've started a "posix" folder in Platform.

That way, standard c function are available to all files.

 

I took the occasion to supply new implementation I found that speeds up A LOT the loading time of an SVG theme. @Slice try it, there is a big difference. It went from 20 seconds to 2/3 !

Link to comment
Share on other sites

 Share

×
×
  • Create New...