MCPcopy
hub / github.com/Eugeny/tabby / ACPI

Function ACPI

tabby-web-demo/data/v86_all.js:368–371  ·  view source on GitHub ↗
(a)

Source from the content-addressed store, hash-verified

366h(p)+" counter="+h(t,2)+" reg="+h(u),LOG_HPET);switch(u){case 0:return n[t<<1]&~HPET_COUNTER_CONFIG_MASK|HPET_COUNTER_CONFIG;case 1:return n[t<<1|1];case 2:return r[t<<1];case 3:return r[t<<1|1];case 4:case 5:return 0}},function(p,u){dbg_log("Write "+h(p,4)+": "+h(u,2),LOG_HPET);switch(p){case 16:dbg_log("conf: enabled="+(u&1)+" legacy="+(u>>1&1),LOG_HPET);(e^u)&1&&(u&1?f=Date.now():(k=b(),g=c()));e=1===(u&1);d.legacy_mode=2===(u&2);return;case 32:m&=~u;return;case 240:k=u;return;case 244:g=u;return}var t=
367p>>2&7,x=p-256>>5;if(256>p||x>=HPET_NUM_COUNTERS||2<t)dbg_log("Write reserved address: "+h(p)+" data="+h(u),LOG_HPET);else switch(dbg_log("Write counter: addr="+h(p)+" counter="+h(x,2)+" reg="+h(t)+" data="+h(u,2),LOG_HPET),t){case 0:n[x<<1]=u;break;case 2:l?(v[x<<1]=u,l=!1,dbg_log("Accumulator acc="+h(u>>>0,8)+" ctr="+h(x,2),LOG_HPET)):(r[x<<1]=u,n[x<<1]&64&&(l=!0,n[x<<1]&=-65));break;case 3:r[x<<1|1]=u}})};var PMTIMER_FREQ_SECONDS=3579545;
368function ACPI(a){this.cpu=a;var b=a.io;a.devices.pci.register_device({pci_id:56,pci_space:[134,128,19,113,7,0,128,2,8,0,128,6,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,1,0,0],pci_bars:[],name:"acpi"});this.timer_imprecision_offset=this.timer_last_value=0;this.status=1;this.pm1_enable=this.pm1_status=0;this.last_timer=this.get_timer(v86.microtick());this.gpe=new Uint8Array(4);b.register_read(45056,this,void 0,function(){dbg_log("ACPI pm1_status read",
369LOG_ACPI);return this.pm1_status});b.register_write(45056,this,void 0,function(c){dbg_log("ACPI pm1_status write: "+h(c,4),LOG_ACPI);this.pm1_status&=~c});b.register_read(45058,this,void 0,function(){dbg_log("ACPI pm1_enable read",LOG_ACPI);return this.pm1_enable});b.register_write(45058,this,void 0,function(c){dbg_log("ACPI pm1_enable write: "+h(c),LOG_ACPI);this.pm1_enable=c});b.register_read(45060,this,void 0,function(){dbg_log("ACPI status read",LOG_ACPI);return this.status});b.register_write(45060,
370this,void 0,function(c){dbg_log("ACPI status write: "+h(c),LOG_ACPI);this.status=c});b.register_read(45064,this,void 0,void 0,function(){return this.get_timer(v86.microtick())&16777215});b.register_read(45024,this,function(){dbg_log("Read gpe#0",LOG_ACPI);return this.gpe[0]});b.register_read(45025,this,function(){dbg_log("Read gpe#1",LOG_ACPI);return this.gpe[1]});b.register_read(45026,this,function(){dbg_log("Read gpe#2",LOG_ACPI);return this.gpe[2]});b.register_read(45027,this,function(){dbg_log("Read gpe#3",
371LOG_ACPI);return this.gpe[3]});b.register_write(45024,this,function(c){dbg_log("Write gpe#0: "+h(c),LOG_ACPI);this.gpe[0]=c});b.register_write(45025,this,function(c){dbg_log("Write gpe#1: "+h(c),LOG_ACPI);this.gpe[1]=c});b.register_write(45026,this,function(c){dbg_log("Write gpe#2: "+h(c),LOG_ACPI);this.gpe[2]=c});b.register_write(45027,this,function(c){dbg_log("Write gpe#3: "+h(c),LOG_ACPI);this.gpe[3]=c})}
372ACPI.prototype.timer=function(a){a=this.get_timer(a);var b=0!==((a^this.last_timer)&8388608);this.pm1_enable&1&&b?(dbg_log("ACPI raise irq",LOG_ACPI),this.pm1_status|=1,this.cpu.device_raise_irq(9)):this.cpu.device_lower_irq(9);this.last_timer=a};
373ACPI.prototype.get_timer=function(a){a=Math.round(PMTIMER_FREQ_SECONDS/1E3*a);a===this.timer_last_value?this.timer_imprecision_offset<PMTIMER_FREQ_SECONDS/1E3&&this.timer_imprecision_offset++:(dbg_assert(a>this.timer_last_value),this.timer_last_value+this.timer_imprecision_offset<=a?(this.timer_imprecision_offset=0,this.timer_last_value=a):dbg_log("Warning: Overshot pmtimer, waiting; current="+a+" last="+this.timer_last_value+" offset="+this.timer_imprecision_offset,LOG_ACPI));return this.timer_last_value+
374this.timer_imprecision_offset};ACPI.prototype.get_state=function(){var a=[];a[0]=this.status;a[1]=this.pm1_status;a[2]=this.pm1_enable;a[3]=this.gpe;return a};ACPI.prototype.set_state=function(a){this.status=a[0];this.pm1_status=a[1];this.pm1_enable=a[2];this.gpe=a[3]};var APIC_LOG_VERBOSE=!1,APIC_ADDRESS=4276092928,APIC_TIMER_MODE_MASK=393216,APIC_TIMER_MODE_ONE_SHOT=0,APIC_TIMER_MODE_PERIODIC=131072,APIC_TIMER_MODE_TSC=262144,DELIVERY_MODES="Fixed (0);Lowest Prio (1);SMI (2);Reserved (3);NMI (4);INIT (5);Reserved (6);ExtINT (7)".split(";"),DESTINATION_MODES=["physical","logical"];

Callers

nothing calls this directly

Calls 1

hFunction · 0.85

Tested by

no test coverage detected