humph Posted February 17, 2011 Share Posted February 17, 2011 ..as I don't have the knowledge of ASM because I did not listen to my dear Dad when I was younger, he said I should study more. Me too. But in the 21st Century we have Google and The Internet. Wonder - does this help: Creating a Kernel Driver for the PC Speaker Link to comment Share on other sites More sharing options...
GrootWitBaas Posted February 17, 2011 Share Posted February 17, 2011 Me too. But in the 21st Century we have Google and The Internet.Wonder - does this help: Creating a Kernel Driver for the PC Speaker That is for a full driver and uses a lot of dependencies from the booted Linux platform. I just need to access the 42h and 43h for setting the timer. I need to do this from within c++ (with no windows.h dependencies ect.) or direct from ASM, but was thinking to use c/c++ ability to use/pass asm instructions. O and I have been there and many other pages, I have examples of the asm code needed, but are unable to get it compiled with my nasm compiler on osx or using the c++ asm calls, see below int main() { asm ("mov al, 182" //{ prepare timer to start generating sound } "out 43h, al" "mov ax, toneout" //{ TONEOUT = word: 1193180 / frequency } "out 42h, al" //{ send low byte to port 42h } "mov al, ah" "out 42h, al" //{ send high byte to port 42h } "in al, 61h" //{ get current value of port 61h } "or al, 3" //{ set lowest two bits of 61h "on" -- activate speaker } "out 61h, al" //{ rewrite to port 61h }" ); //sleep(1); //wait one second before turn off asm ("in al, 61h" //{ set lowest two bits of 61h "off" -- deactive speaker } "and al, 252" //{ this line turns the lowest two bits "off" } "out 61h, al" ); } Gives me a compile error of $ g++ beep3.c -o beep3 /var/folders/cj/cj46LyZzFcu3rcdW8X40GU+++TI/-Tmp-//ccYS11uE.s:9:too many memory references for `mov' /var/folders/cj/cj46LyZzFcu3rcdW8X40GU+++TI/-Tmp-//ccYS11uE.s:10:too many memory references for `in' $ and this should produce a beep (or with no pause just a tic) Edit: add a good link to information Link to comment Share on other sites More sharing options...
dgsga Posted February 17, 2011 Share Posted February 17, 2011 I know this is possible, I just were not able to do it yet, as I don't have the knowledge of ASM because I did not listen to my dear Dad when I was younger, he said I should study more. Groot Groot, To get the chime working would be well on the way to nirvana . I have saved the speaker from my G5 case for this very thing. Link to comment Share on other sites More sharing options...
GrootWitBaas Posted February 17, 2011 Share Posted February 17, 2011 You have a modded G5 case you use ? If so a Picture please ...My G5 case is still standing here waiting for me to mod it Link to comment Share on other sites More sharing options...
GrootWitBaas Posted February 17, 2011 Share Posted February 17, 2011 @GrootWitBaas: Just an idea of course, but I would start by exploring the original firmware to see how Apple does this, and copy bits and pieces from it They do it before boot0 is loaded, right from the "bios" chip, just before boot0 is called ...well at least that is the way it looks to me atm. I have all the source of 10.4.8 downloaded (to include boot 321) but so far I can't seem to get it done. If only I can get the in-line asm to run the asm I pass to it But I won't give up, that's why I asked the ASM gurus here, and I kind of like to make this my personal goal to be able to get this working. Link to comment Share on other sites More sharing options...
dgsga Posted February 17, 2011 Share Posted February 17, 2011 You have a modded G5 case you use ? If so a Picture please ...My G5 case is still standing here waiting for me to mod it Groot, Will post photo when I finish work. G5 case is perfect for mATX boards Link to comment Share on other sites More sharing options...
GrootWitBaas Posted February 17, 2011 Share Posted February 17, 2011 That's why I said to explore the firmware (EFI ROM firmware to be exact) which is where the magic can be found.It's good to see you trying, as much as you possibly can, ... Well I have a beep, just not a chime, it should work for all. The 1st possible place where I get this to work is in boot.c if you want to test just add the red line here in boot.c #endif initPlatform(biosdev); // Passing on the boot drive. [color="#FF0000"]printf("\a");[/color] #if DEBUG_ACPI || DEBUG_BOOT || DEBUG_CPU || DEBUG_DISK || .... from my tests this is the 1st place where it works. Not sure why it does not work before this, but will check. This gives a place where we can address the pc internal speaker, and if we can in the end find a way to Link to comment Share on other sites More sharing options...
humph Posted February 17, 2011 Share Posted February 17, 2011 ...This gives a place where we can address the pc internal speaker, and if we can in the end find a way to... Further to your asm stuff above. Figured it might be due to use of gcc in OSX that can't handle Intel format and needs AT&T format. So below compiles...(not complete, left the off stuff for comparison) although it's probably not correct as I have no idea if toneout should be int or smth else.. // AT&T source, destination int toneout=1193180/1000; int main() { asm ("movb 0x4b, %al;" //{ prepare timer to start generating sound } "outb %al, $0x43;" "movw $toneout, %ax;" //{ TONEOUT = word: 1193180 / frequency } "outw %ax, $0x42;" //{ send low byte to port 42h } "movb %al, %ah;" "outb %al, $0x42;" //{ send high byte to port 42h } "inb $0x61, %al;" //{ get current value of port 61h } "or %al, 3;" //{ set lowest two bits of 61h "on" -- activate speaker } "outb %al, $0x61;" //{ rewrite to port 61h }" ); /* ); //sleep(1); //wait one second before turn off asm ("in 61h, al;" //{ set lowest two bits of 61h "off" -- deactive speaker } "and 252, al;" //{ this line turns the lowest two bits "off" } "out al, 61h;" ); */ } Link to comment Share on other sites More sharing options...
GrootWitBaas Posted February 17, 2011 Share Posted February 17, 2011 Further to your asm stuff above. Figured it might be due to use of gcc in OSX that can't handle Intel format and needs AT&T format. So below compiles...(not complete, left the off stuff for comparison) although it's probably not correct as I have no idea if toneout should be int or smth else.. // AT&T source, destination ... Ok I have this now : #include <stdio.h> int main() { int toneout=1193180/1000; // AT&T source, destination asm ("movb 0x4b, %al;" //{ prepare timer to start generating sound } "outb %al, $0x43;" "movw $toneout, %ax;" //{ TONEOUT = word: 1193180 / frequency } "outw %ax, $0x42;" //{ send low byte to port 42h } "movb %al, %ah;" "outb %al, $0x42;" //{ send high byte to port 42h } "inb $0x61, %al;" //{ get current value of port 61h } "or %al, 3;" //{ set lowest two bits of 61h "on" -- activate speaker } "outb %al, $0x61;" //{ rewrite to port 61h }" ); getchar(); //just for delay to turn off asm ("inb $0x61, %al;" //{ set lowest two bits of 61h "off" -- deactive speaker } "or %al, 252;" //{ set lowest two bits of 61h "on" -- activate speaker } "outb %al, $0x61;"//{ rewrite to port 61h }" ); } Did I do the last part correctly ? also I think from the compiler error that maybe toneout should be something else, Here is the error I get : ld: in /var/folders/cj/cj46LyZzFcu3rcdW8X40GU+++TI/-Tmp-//ccQnHybN.o, in section __TEXT,__text reloc 1: length < 2 and X86_64_RELOC_UNSIGNED not supported collect2: ld returned 1 exit status but thanks for the pointer about at&t, that will make my google give other examples and then i see a replay from DHP Hi humph, Have a look at cpu/proc_reg.h where you'll find two functions that can be used to enable/disable the PC speaker. The easy way. Also good code (examples) to get you gentlemen started. In the right direction Thanks ....that's what I was looking for .... Let me go test / play / google / read Link to comment Share on other sites More sharing options...
dgsga Posted February 17, 2011 Share Posted February 17, 2011 Well I have a beep, just not a chime, it should work for all. The 1st possible place where I get this to work is in boot.c if you want to test just add the red line here in boot.c #endif initPlatform(biosdev); // Passing on the boot drive. [color="#FF0000"]printf("\a");[/color] #if DEBUG_ACPI || DEBUG_BOOT || DEBUG_CPU || DEBUG_DISK || .... from my tests this is the 1st place where it works. Not sure why it does not work before this, but will check. This gives a place where we can address the pc internal speaker, and if we can in the end find a way to Hi Groot Works for me. For all those lucky people with an Asus laptop which plays a sound on POST you can use mmtool to replace your embedded post sound in the bios with the mac startup chime in 8-bit wav format. Here's the requested photo: Link to comment Share on other sites More sharing options...
blackosx Posted February 17, 2011 Share Posted February 17, 2011 Just used Google to find that. ah.. the wonder of our friend Google. I'd place Settings Under MakeAcpi in MakeStatic AND change the MakeAcpi in MakeMedia to MakeStatic. Done. And I've also moved the calls to the compile functions in MakeMedia from before the check for Extra/Extensions to after the check has passed. This way it won't compile twice if the code has stopped to ask the user to add their /Extra/Extensions. Link to comment Share on other sites More sharing options...
dgsga Posted February 17, 2011 Share Posted February 17, 2011 Do you happen to know the size of this sound file? Also. A stripped BIOS file might help us/people to get a boot chime going. Here it is! The module that needs replacing in the bios is the FA module. Not sure what you mean by a stripped BIOS file, can you expand further? EDIT: Here is file saved at correct 24kHz frequency: chime3.wav Link to comment Share on other sites More sharing options...
GrootWitBaas Posted February 17, 2011 Share Posted February 17, 2011 ok I will have a look at making a new thread for this, But want it to stay kind off a sub section of this thread .... Striped bios means we need the module removed and decompiled ...looks like I will have to use windowzzzz or Linux in the end to get this running ...I want to do it from OSX but keep running into limitations. I won't make the thread right now, but will do it tomorrow and post here when done. Link to comment Share on other sites More sharing options...
blackosx Posted February 18, 2011 Share Posted February 18, 2011 I'm putting together a ReadMe which I intend to distribute with the RevStart script. At the moment it gives an overview of Revolution for new users interested in trying it out. I've attached what I have so far, with the idea of anybody wanting to look it it can give comment while it's still at this stage. It's not meant to be too in-depth, just enough to give somebody interested an idea of how and what etc.. ReadMe.rtf Link to comment Share on other sites More sharing options...
GrootWitBaas Posted February 18, 2011 Share Posted February 18, 2011 @GrootWitBaasThe speaker thing is a good idea, but some PC's don't have speaker.Probably per user choice I suppose. I myself use SystemSound, it plays a <=10 second ??.mp3 (you can choose) at login and also logout. It uses Quicktime so will play anything that does.Mine is Take My Hand from Dune. Fantastic. As far as I am aware, 99% of all pc's does have a internal speaker(I have never seen one without, but have been proven wrong before hence only 99%), because it is the only warning means if there is a GFX/RAM error during post. Even EFI systems have this, because again it is the only way to "communicate" without using RAM if there is no video, hence why you get a beep error if all ram is removed or if GFX is removed. some are just a basic buzzer type, others are a full speaker. If you have not connected your when you build your case, well then to have this working you need to add it. Our idea is to have the Dong at almost the same time as a real mack, very early boot. I'm putting together a ReadMe which I intend to distribute with the RevStart script. ...It's not meant to be too in-depth, just enough to give somebody interested an idea of how and what etc.. You are always good at these thing, keep it up Now I have done as requested, here is the new topic for the boot sound Link to comment Share on other sites More sharing options...
blackosx Posted February 18, 2011 Share Posted February 18, 2011 You are always good at these thing, keep it up Thanks Groot - You're too kind Good luck with your boot audio project.. Maybe one day i'll get to hear the chime at boot time on my hack. This project is getting more and more exiting. Thanks to everyone involved, so please add a credits paragraph because without people like yourself... we wouldn't be this far. No way! Thanks for the kind words DHP. All I did and am still doing is recognise your dedication and hard work here. What you're doing is exciting and it's great to feel part of something that's maturing each week. I've a lot more to add to the ReadMe and RevStart etc.. so I'll add some names in then. More good news; I am about to attach my new SMBIOS structure stripper (two files) and I called it smbios2struct2. This will soon be the successor of smbios2struct.... with your help of course Fantastic - more great work from yourself. Well done. I've just tested it on my iMac and I now have 88 lines of hex as opposed to 136 from v1 of smbios2struct. I'll run it on my hack this evening. EDIT: Back home now at my hack, tested and booted successfully. I see no noticeable difference with my system meaning everything is still present and correct in System Profiler using the new smaller static SMBIOS data (24 lines now, vs 45 lines previously). Great job. I'll do more testing later. @ blackosxA couple of bugfixes/tidyups to Revstart Hi STLVNUB Good work with your updates to the Revstart script and I'll test it out later. Yes the >> appends to a file which I had spotted but hadn't changed yet. And I like your idea of furthering the Project to support the EFI system partition and (maybe) RAID support too, although I haven't used the EFI system partition install method since running with it for a few months after first reading Munky's post. And I don't have a RAID setup so I will be unable to test there. I've also been tweaking a version at home so I'll look at combining the changes when I can. I had been re-structing / re-wording the options to make it, IMO, less complicated when looking at at first glance. I was also thinking of making a simpler version with only a couple of options? Yes, the code I added should find and add the static data for any ACPI table as long as it's in the STATIC folder. p.s. 24 hours!.. that's a long day. Link to comment Share on other sites More sharing options...
DB1 Posted February 18, 2011 Share Posted February 18, 2011 More good news; I am about to attach my new SMBIOS structure stripper (two files) and I called it smbios2struct2. This will soon be the successor of smbios2struct.... with your help of course ........ 1.) Add libsaio/smbios/util 2.) Copy files into this new directory. 3.) Compile (see file header). 4.) run: ./smbios2struct2 5.) Copy the output into smbios/data.h 6.) open libsaio/smbios/static_data.h and make this little change: -STATIC_SMBIOS_SM_STRUCTURE_SIZE +STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE 7.) Compile Revolution and see what it does for you. So far part I. See attached files (smbios.h taking from XNU source code and changed where required). Hi DHP, you been busy again. I get compile warning - dont know if this a problem because it compiles: smbios2struct2.c: In function ‘main’: smbios2struct2.c:291: warning: format ‘%08x’ expects type ‘unsigned int’, but argument 2 has type ‘UInt32’ I get Revolution compile error: smbios.c: In function ‘setupSMBIOS’: smbios.c:33: error: ‘STATIC_SMBIOS_SM_MAX_STRUCTURE_SIZE’ undeclared (first use in this function) smbios.c:33: error: (Each undeclared identifier is reported only once smbios.c:33: error: for each function it appears in.) make[2]: *** [smbios.o] Error 1 make[1]: *** [all] Error 2 make: *** [all] Error 2 Link to comment Share on other sites More sharing options...
DB1 Posted February 18, 2011 Share Posted February 18, 2011 Hi DB1, Thank you. Good catch – the error was fixed before, but I lost a HDD and thus used outdated code. Should be fine in the attached update. See point 7 (newly added / thanks) in my previous post (only had time for a few runs with static data, on two hacks). Gone for hockey training. Back later. Now thats the compile warning gone with the new file but I cannot compile with 6 & 7, getting the same Revolution compile error. BUT WOW, without doing 6 & 7 it compiles and the resulting boot is a massive 10 turns less on the throbber! Your making ground now, I think this my biggest (noticeable) improvement so far. Great stuff DHP, keep it up.....and thanks again Link to comment Share on other sites More sharing options...
dgsga Posted February 18, 2011 Share Posted February 18, 2011 7.) Apply the same fix to libsaio/smbios.c Hey DHP, don't you mean config/SMBIOS/data.h, this is the only way I can get rev to compile Link to comment Share on other sites More sharing options...
DB1 Posted February 18, 2011 Share Posted February 18, 2011 If you guys are using Revstart to compile, then THAT is the PROBLEM.Revstart needs to us the NEW smbios2struct2 to make it compile successfully. Well it did here IF you want to fix it Do point 6 Compile smbios2struct2 and copy it to the Tools folder and edit Revstart??.command and replace smbios2struct with smbios2struct2. smbios2struct2 compiles fine the way DHP advised (command line smbios/util ./smbios2struct) with the revised file (post #1056) it's Revolution that I cannot get to compile with addition of instruction 6 or 6 & 7. Link to comment Share on other sites More sharing options...
DB1 Posted February 18, 2011 Share Posted February 18, 2011 Hey DHP, don't you mean config/SMBIOS/data.h, this is the only way I can get rev to compile Thanks dgsga, it works this way for me also. EDIT 1st boot tonight was 7 seconds from post to grey screen and apple, 5 seconds to throbber and 31 turns. 2nd boot after smbios changes 7/5/21, after permissions repair next boot 7/5/17.5 - almost half the time through the thobber phase! Here's my current build:RevolutionReleaseDB1.zip In so far as I can remember the only changes I made to RevolutionRelease until most recent was forcing MBP6.1 in smbios/dynamic_data.h Link to comment Share on other sites More sharing options...
blackosx Posted February 18, 2011 Share Posted February 18, 2011 Wow.. DB1.. You're seeing quite an improvement at your end. I don't see much difference with boot speed to be honest, though I need to do more testing. Note: I didn't have any issues building Revolution with the latest changes here. Will it help if I post what I have here? @DHP - I haven't done much testing since I've been building my code from the Revolution-Release in post #986 and the last version I've been booting from HDD with was the last tweak we made to rev-641. Anyway, I've just tried booting from HDD with the latest build and I've noticed that regardless of the drive order in BIOS, Revolution always boots my OS X installation on HDD 0 (as seen by the BIOS) and not on HDD 1? Where as before with rev-641, changing the drive order in BIOS allowed me to boot a different OS X instalaltion on a different HDD. I'll enable my debug and post what happens.... Back soon. Link to comment Share on other sites More sharing options...
blackosx Posted February 18, 2011 Share Posted February 18, 2011 I'll enable my debug and post what happens.... Back soon. I guess that it depends on the BIOS (smbios data) but why don't you set VERBOSE to 1 and tell us what you see. How many / which structures are dropped ... Can't exactly recall what I changed. Will have a look tomorrow. I've built a boot file with all debugs turned on and recorded four boots. Hopefully it might show you what's going on. But to recap, I can only boot in to my OS X installation on HDD 1 from USB and not from HDD, regardless of default drive setting in BIOS. 1. Default HDD in BIOS = 0 / Select to boot HDD 0 from boot menu / Boots in to OS X on HDD 0 2. Default HDD in BIOS = 1 / Select to boot HDD 0 from boot menu / Boots in to OS X on HDD 0 3. Default HDD in BIOS = 0 / Select to boot USB from boot menu / Boots in to OS X on HDD 0 4. Default HDD in BIOS = 1 / Select to boot USB from boot menu / Boots in to OS X on HDD 1 I'm too tired now (worked so hard to get the source code ready). Sorry. Good night. No problem.. Enjoy a good night's sleep Link to comment Share on other sites More sharing options...
DB1 Posted February 18, 2011 Share Posted February 18, 2011 No, but it is too confusing (even for me) so I will eliminate two of them right now... Wow! What can I say? I'm too tired now (worked so hard to get the source code ready). Sorry. Good night. Sweet dreams, you had a tough week with all the travel, hockey, school and working on this, get some R & R. The template was same as I already had, did not diff the other two files just put them in and compiled and boots fine on EFI partition (and fast) will try on SDcard tomorrow. I'm done as well. Link to comment Share on other sites More sharing options...
GrootWitBaas Posted February 18, 2011 Share Posted February 18, 2011 That was then And on boot time, I am down to 29,5 seconds taking the same measurement as before from selecting the drive until browser open on this page. AND This is NOW, a whole 4,5 seconds gone WOW. Boot time with exact same test 25,0 seconds. I am Impressed ....Never thought my old hack will boot in under 45, never-mind 25 Link to comment Share on other sites More sharing options...
Recommended Posts