1 #include "qemu/osdep.h"
2 #include "hw/acpi/memory_hotplug.h"
3 #include "hw/acpi/pc-hotplug.h"
4 #include "hw/mem/pc-dimm.h"
6 #include "hw/qdev-core.h"
8 #include "qapi-event.h"
10 static ACPIOSTInfo
*acpi_memory_device_status(int slot
, MemStatus
*mdev
)
12 ACPIOSTInfo
*info
= g_new0(ACPIOSTInfo
, 1);
14 info
->slot_type
= ACPI_SLOT_TYPE_DIMM
;
15 info
->slot
= g_strdup_printf("%d", slot
);
16 info
->source
= mdev
->ost_event
;
17 info
->status
= mdev
->ost_status
;
19 DeviceState
*dev
= DEVICE(mdev
->dimm
);
21 info
->device
= g_strdup(dev
->id
);
22 info
->has_device
= true;
28 void acpi_memory_ospm_status(MemHotplugState
*mem_st
, ACPIOSTInfoList
***list
)
32 for (i
= 0; i
< mem_st
->dev_count
; i
++) {
33 ACPIOSTInfoList
*elem
= g_new0(ACPIOSTInfoList
, 1);
34 elem
->value
= acpi_memory_device_status(i
, &mem_st
->devs
[i
]);
41 static uint64_t acpi_memory_hotplug_read(void *opaque
, hwaddr addr
,
45 MemHotplugState
*mem_st
= opaque
;
49 if (mem_st
->selector
>= mem_st
->dev_count
) {
50 trace_mhp_acpi_invalid_slot_selected(mem_st
->selector
);
54 mdev
= &mem_st
->devs
[mem_st
->selector
];
55 o
= OBJECT(mdev
->dimm
);
57 case 0x0: /* Lo part of phys address where DIMM is mapped */
58 val
= o
? object_property_get_int(o
, PC_DIMM_ADDR_PROP
, NULL
) : 0;
59 trace_mhp_acpi_read_addr_lo(mem_st
->selector
, val
);
61 case 0x4: /* Hi part of phys address where DIMM is mapped */
62 val
= o
? object_property_get_int(o
, PC_DIMM_ADDR_PROP
, NULL
) >> 32 : 0;
63 trace_mhp_acpi_read_addr_hi(mem_st
->selector
, val
);
65 case 0x8: /* Lo part of DIMM size */
66 val
= o
? object_property_get_int(o
, PC_DIMM_SIZE_PROP
, NULL
) : 0;
67 trace_mhp_acpi_read_size_lo(mem_st
->selector
, val
);
69 case 0xc: /* Hi part of DIMM size */
70 val
= o
? object_property_get_int(o
, PC_DIMM_SIZE_PROP
, NULL
) >> 32 : 0;
71 trace_mhp_acpi_read_size_hi(mem_st
->selector
, val
);
73 case 0x10: /* node proximity for _PXM method */
74 val
= o
? object_property_get_int(o
, PC_DIMM_NODE_PROP
, NULL
) : 0;
75 trace_mhp_acpi_read_pxm(mem_st
->selector
, val
);
77 case 0x14: /* pack and return is_* fields */
78 val
|= mdev
->is_enabled
? 1 : 0;
79 val
|= mdev
->is_inserting
? 2 : 0;
80 val
|= mdev
->is_removing
? 4 : 0;
81 trace_mhp_acpi_read_flags(mem_st
->selector
, val
);
90 static void acpi_memory_hotplug_write(void *opaque
, hwaddr addr
, uint64_t data
,
93 MemHotplugState
*mem_st
= opaque
;
96 DeviceState
*dev
= NULL
;
97 HotplugHandler
*hotplug_ctrl
= NULL
;
98 Error
*local_err
= NULL
;
100 if (!mem_st
->dev_count
) {
105 if (mem_st
->selector
>= mem_st
->dev_count
) {
106 trace_mhp_acpi_invalid_slot_selected(mem_st
->selector
);
112 case 0x0: /* DIMM slot selector */
113 mem_st
->selector
= data
;
114 trace_mhp_acpi_write_slot(mem_st
->selector
);
116 case 0x4: /* _OST event */
117 mdev
= &mem_st
->devs
[mem_st
->selector
];
119 /* TODO: handle device insert OST event */
120 } else if (data
== 3) {
121 /* TODO: handle device remove OST event */
123 mdev
->ost_event
= data
;
124 trace_mhp_acpi_write_ost_ev(mem_st
->selector
, mdev
->ost_event
);
126 case 0x8: /* _OST status */
127 mdev
= &mem_st
->devs
[mem_st
->selector
];
128 mdev
->ost_status
= data
;
129 trace_mhp_acpi_write_ost_status(mem_st
->selector
, mdev
->ost_status
);
130 /* TODO: implement memory removal on guest signal */
132 info
= acpi_memory_device_status(mem_st
->selector
, mdev
);
133 qapi_event_send_acpi_device_ost(info
, &error_abort
);
134 qapi_free_ACPIOSTInfo(info
);
136 case 0x14: /* set is_* fields */
137 mdev
= &mem_st
->devs
[mem_st
->selector
];
138 if (data
& 2) { /* clear insert event */
139 mdev
->is_inserting
= false;
140 trace_mhp_acpi_clear_insert_evt(mem_st
->selector
);
141 } else if (data
& 4) {
142 mdev
->is_removing
= false;
143 trace_mhp_acpi_clear_remove_evt(mem_st
->selector
);
144 } else if (data
& 8) {
145 if (!mdev
->is_enabled
) {
146 trace_mhp_acpi_ejecting_invalid_slot(mem_st
->selector
);
150 dev
= DEVICE(mdev
->dimm
);
151 hotplug_ctrl
= qdev_get_hotplug_handler(dev
);
152 /* call pc-dimm unplug cb */
153 hotplug_handler_unplug(hotplug_ctrl
, dev
, &local_err
);
155 trace_mhp_acpi_pc_dimm_delete_failed(mem_st
->selector
);
156 qapi_event_send_mem_unplug_error(dev
->id
,
157 error_get_pretty(local_err
),
159 error_free(local_err
);
162 trace_mhp_acpi_pc_dimm_deleted(mem_st
->selector
);
170 static const MemoryRegionOps acpi_memory_hotplug_ops
= {
171 .read
= acpi_memory_hotplug_read
,
172 .write
= acpi_memory_hotplug_write
,
173 .endianness
= DEVICE_LITTLE_ENDIAN
,
175 .min_access_size
= 1,
176 .max_access_size
= 4,
180 void acpi_memory_hotplug_init(MemoryRegion
*as
, Object
*owner
,
181 MemHotplugState
*state
)
183 MachineState
*machine
= MACHINE(qdev_get_machine());
185 state
->dev_count
= machine
->ram_slots
;
186 if (!state
->dev_count
) {
190 state
->devs
= g_malloc0(sizeof(*state
->devs
) * state
->dev_count
);
191 memory_region_init_io(&state
->io
, owner
, &acpi_memory_hotplug_ops
, state
,
192 "acpi-mem-hotplug", ACPI_MEMORY_HOTPLUG_IO_LEN
);
193 memory_region_add_subregion(as
, ACPI_MEMORY_HOTPLUG_BASE
, &state
->io
);
197 * acpi_memory_slot_status:
198 * @mem_st: memory hotplug state
200 * @errp: set in case of an error
202 * Obtain a single memory slot status.
204 * This function will be called by memory unplug request cb and unplug cb.
207 acpi_memory_slot_status(MemHotplugState
*mem_st
,
208 DeviceState
*dev
, Error
**errp
)
210 Error
*local_err
= NULL
;
211 int slot
= object_property_get_int(OBJECT(dev
), PC_DIMM_SLOT_PROP
,
215 error_propagate(errp
, local_err
);
219 if (slot
>= mem_st
->dev_count
) {
220 char *dev_path
= object_get_canonical_path(OBJECT(dev
));
221 error_setg(errp
, "acpi_memory_slot_status: "
222 "device [%s] returned invalid memory slot[%d]",
228 return &mem_st
->devs
[slot
];
231 void acpi_memory_plug_cb(HotplugHandler
*hotplug_dev
, MemHotplugState
*mem_st
,
232 DeviceState
*dev
, Error
**errp
)
235 DeviceClass
*dc
= DEVICE_GET_CLASS(dev
);
237 if (!dc
->hotpluggable
) {
241 mdev
= acpi_memory_slot_status(mem_st
, dev
, errp
);
247 mdev
->is_enabled
= true;
248 if (dev
->hotplugged
) {
249 mdev
->is_inserting
= true;
250 acpi_send_event(DEVICE(hotplug_dev
), ACPI_MEMORY_HOTPLUG_STATUS
);
254 void acpi_memory_unplug_request_cb(HotplugHandler
*hotplug_dev
,
255 MemHotplugState
*mem_st
,
256 DeviceState
*dev
, Error
**errp
)
260 mdev
= acpi_memory_slot_status(mem_st
, dev
, errp
);
265 mdev
->is_removing
= true;
266 acpi_send_event(DEVICE(hotplug_dev
), ACPI_MEMORY_HOTPLUG_STATUS
);
269 void acpi_memory_unplug_cb(MemHotplugState
*mem_st
,
270 DeviceState
*dev
, Error
**errp
)
274 mdev
= acpi_memory_slot_status(mem_st
, dev
, errp
);
279 mdev
->is_enabled
= false;
283 static const VMStateDescription vmstate_memhp_sts
= {
284 .name
= "memory hotplug device state",
286 .minimum_version_id
= 1,
287 .minimum_version_id_old
= 1,
288 .fields
= (VMStateField
[]) {
289 VMSTATE_BOOL(is_enabled
, MemStatus
),
290 VMSTATE_BOOL(is_inserting
, MemStatus
),
291 VMSTATE_UINT32(ost_event
, MemStatus
),
292 VMSTATE_UINT32(ost_status
, MemStatus
),
293 VMSTATE_END_OF_LIST()
297 const VMStateDescription vmstate_memory_hotplug
= {
298 .name
= "memory hotplug state",
300 .minimum_version_id
= 1,
301 .minimum_version_id_old
= 1,
302 .fields
= (VMStateField
[]) {
303 VMSTATE_UINT32(selector
, MemHotplugState
),
304 VMSTATE_STRUCT_VARRAY_POINTER_UINT32(devs
, MemHotplugState
, dev_count
,
305 vmstate_memhp_sts
, MemStatus
),
306 VMSTATE_END_OF_LIST()
310 void build_memory_hotplug_aml(Aml
*ctx
, uint32_t nr_mem
,
311 uint16_t io_base
, uint16_t io_len
)
318 /* scope for memory hotplug controller device node */
319 pci_scope
= aml_scope("_SB.PCI0");
320 mem_ctrl_dev
= aml_device(MEMORY_HOTPLUG_DEVICE
);
322 Aml
*one
= aml_int(1);
323 Aml
*zero
= aml_int(0);
324 Aml
*ret_val
= aml_local(0);
325 Aml
*slot_arg0
= aml_arg(0);
326 Aml
*slots_nr
= aml_name(MEMORY_SLOTS_NUMBER
);
327 Aml
*ctrl_lock
= aml_name(MEMORY_SLOT_LOCK
);
328 Aml
*slot_selector
= aml_name(MEMORY_SLOT_SLECTOR
);
330 aml_append(mem_ctrl_dev
, aml_name_decl("_HID", aml_string("PNP0A06")));
331 aml_append(mem_ctrl_dev
,
332 aml_name_decl("_UID", aml_string("Memory hotplug resources")));
334 method
= aml_method("_STA", 0, AML_NOTSERIALIZED
);
335 ifctx
= aml_if(aml_equal(slots_nr
, zero
));
337 aml_append(ifctx
, aml_return(zero
));
339 aml_append(method
, ifctx
);
340 /* present, functioning, decoding, not shown in UI */
341 aml_append(method
, aml_return(aml_int(0xB)));
342 aml_append(mem_ctrl_dev
, method
);
344 aml_append(mem_ctrl_dev
, aml_mutex(MEMORY_SLOT_LOCK
, 0));
346 method
= aml_method(MEMORY_SLOT_SCAN_METHOD
, 0, AML_NOTSERIALIZED
);
350 Aml
*idx
= aml_local(0);
351 Aml
*eject_req
= aml_int(3);
352 Aml
*dev_chk
= aml_int(1);
354 ifctx
= aml_if(aml_equal(slots_nr
, zero
));
356 aml_append(ifctx
, aml_return(zero
));
358 aml_append(method
, ifctx
);
360 aml_append(method
, aml_store(zero
, idx
));
361 aml_append(method
, aml_acquire(ctrl_lock
, 0xFFFF));
363 * loops over all slots and Notifies DIMMs with
364 * Device Check or Eject Request notifications if
365 * slot has corresponding status bit set and clears
368 while_ctx
= aml_while(aml_lless(idx
, slots_nr
));
370 Aml
*ins_evt
= aml_name(MEMORY_SLOT_INSERT_EVENT
);
371 Aml
*rm_evt
= aml_name(MEMORY_SLOT_REMOVE_EVENT
);
373 aml_append(while_ctx
, aml_store(idx
, slot_selector
));
374 ifctx
= aml_if(aml_equal(ins_evt
, one
));
377 aml_call2(MEMORY_SLOT_NOTIFY_METHOD
,
379 aml_append(ifctx
, aml_store(one
, ins_evt
));
381 aml_append(while_ctx
, ifctx
);
383 else_ctx
= aml_else();
384 ifctx
= aml_if(aml_equal(rm_evt
, one
));
387 aml_call2(MEMORY_SLOT_NOTIFY_METHOD
,
389 aml_append(ifctx
, aml_store(one
, rm_evt
));
391 aml_append(else_ctx
, ifctx
);
392 aml_append(while_ctx
, else_ctx
);
394 aml_append(while_ctx
, aml_add(idx
, one
, idx
));
396 aml_append(method
, while_ctx
);
397 aml_append(method
, aml_release(ctrl_lock
));
398 aml_append(method
, aml_return(one
));
400 aml_append(mem_ctrl_dev
, method
);
402 method
= aml_method(MEMORY_SLOT_STATUS_METHOD
, 1, AML_NOTSERIALIZED
);
404 Aml
*slot_enabled
= aml_name(MEMORY_SLOT_ENABLED
);
406 aml_append(method
, aml_store(zero
, ret_val
));
407 aml_append(method
, aml_acquire(ctrl_lock
, 0xFFFF));
409 aml_store(aml_to_integer(slot_arg0
), slot_selector
));
411 ifctx
= aml_if(aml_equal(slot_enabled
, one
));
413 aml_append(ifctx
, aml_store(aml_int(0xF), ret_val
));
415 aml_append(method
, ifctx
);
417 aml_append(method
, aml_release(ctrl_lock
));
418 aml_append(method
, aml_return(ret_val
));
420 aml_append(mem_ctrl_dev
, method
);
422 method
= aml_method(MEMORY_SLOT_CRS_METHOD
, 1, AML_SERIALIZED
);
424 Aml
*mr64
= aml_name("MR64");
425 Aml
*mr32
= aml_name("MR32");
426 Aml
*crs_tmpl
= aml_resource_template();
427 Aml
*minl
= aml_name("MINL");
428 Aml
*minh
= aml_name("MINH");
429 Aml
*maxl
= aml_name("MAXL");
430 Aml
*maxh
= aml_name("MAXH");
431 Aml
*lenl
= aml_name("LENL");
432 Aml
*lenh
= aml_name("LENH");
434 aml_append(method
, aml_acquire(ctrl_lock
, 0xFFFF));
435 aml_append(method
, aml_store(aml_to_integer(slot_arg0
),
439 aml_qword_memory(AML_POS_DECODE
, AML_MIN_FIXED
, AML_MAX_FIXED
,
440 AML_CACHEABLE
, AML_READ_WRITE
,
441 0, 0x0, 0xFFFFFFFFFFFFFFFEULL
, 0,
442 0xFFFFFFFFFFFFFFFFULL
));
443 aml_append(method
, aml_name_decl("MR64", crs_tmpl
));
445 aml_create_dword_field(mr64
, aml_int(14), "MINL"));
447 aml_create_dword_field(mr64
, aml_int(18), "MINH"));
449 aml_create_dword_field(mr64
, aml_int(38), "LENL"));
451 aml_create_dword_field(mr64
, aml_int(42), "LENH"));
453 aml_create_dword_field(mr64
, aml_int(22), "MAXL"));
455 aml_create_dword_field(mr64
, aml_int(26), "MAXH"));
458 aml_store(aml_name(MEMORY_SLOT_ADDR_HIGH
), minh
));
460 aml_store(aml_name(MEMORY_SLOT_ADDR_LOW
), minl
));
462 aml_store(aml_name(MEMORY_SLOT_SIZE_HIGH
), lenh
));
464 aml_store(aml_name(MEMORY_SLOT_SIZE_LOW
), lenl
));
466 /* 64-bit math: MAX = MIN + LEN - 1 */
467 aml_append(method
, aml_add(minl
, lenl
, maxl
));
468 aml_append(method
, aml_add(minh
, lenh
, maxh
));
469 ifctx
= aml_if(aml_lless(maxl
, minl
));
471 aml_append(ifctx
, aml_add(maxh
, one
, maxh
));
473 aml_append(method
, ifctx
);
474 ifctx
= aml_if(aml_lless(maxl
, one
));
476 aml_append(ifctx
, aml_subtract(maxh
, one
, maxh
));
478 aml_append(method
, ifctx
);
479 aml_append(method
, aml_subtract(maxl
, one
, maxl
));
481 /* return 32-bit _CRS if addr/size is in low mem */
482 /* TODO: remove it since all hotplugged DIMMs are in high mem */
483 ifctx
= aml_if(aml_equal(maxh
, zero
));
485 crs_tmpl
= aml_resource_template();
487 aml_dword_memory(AML_POS_DECODE
, AML_MIN_FIXED
,
488 AML_MAX_FIXED
, AML_CACHEABLE
,
490 0, 0x0, 0xFFFFFFFE, 0,
492 aml_append(ifctx
, aml_name_decl("MR32", crs_tmpl
));
494 aml_create_dword_field(mr32
, aml_int(10), "MIN"));
496 aml_create_dword_field(mr32
, aml_int(14), "MAX"));
498 aml_create_dword_field(mr32
, aml_int(22), "LEN"));
499 aml_append(ifctx
, aml_store(minl
, aml_name("MIN")));
500 aml_append(ifctx
, aml_store(maxl
, aml_name("MAX")));
501 aml_append(ifctx
, aml_store(lenl
, aml_name("LEN")));
503 aml_append(ifctx
, aml_release(ctrl_lock
));
504 aml_append(ifctx
, aml_return(mr32
));
506 aml_append(method
, ifctx
);
508 aml_append(method
, aml_release(ctrl_lock
));
509 aml_append(method
, aml_return(mr64
));
511 aml_append(mem_ctrl_dev
, method
);
513 method
= aml_method(MEMORY_SLOT_PROXIMITY_METHOD
, 1,
516 Aml
*proximity
= aml_name(MEMORY_SLOT_PROXIMITY
);
518 aml_append(method
, aml_acquire(ctrl_lock
, 0xFFFF));
519 aml_append(method
, aml_store(aml_to_integer(slot_arg0
),
521 aml_append(method
, aml_store(proximity
, ret_val
));
522 aml_append(method
, aml_release(ctrl_lock
));
523 aml_append(method
, aml_return(ret_val
));
525 aml_append(mem_ctrl_dev
, method
);
527 method
= aml_method(MEMORY_SLOT_OST_METHOD
, 4, AML_NOTSERIALIZED
);
529 Aml
*ost_evt
= aml_name(MEMORY_SLOT_OST_EVENT
);
530 Aml
*ost_status
= aml_name(MEMORY_SLOT_OST_STATUS
);
532 aml_append(method
, aml_acquire(ctrl_lock
, 0xFFFF));
533 aml_append(method
, aml_store(aml_to_integer(slot_arg0
),
535 aml_append(method
, aml_store(aml_arg(1), ost_evt
));
536 aml_append(method
, aml_store(aml_arg(2), ost_status
));
537 aml_append(method
, aml_release(ctrl_lock
));
539 aml_append(mem_ctrl_dev
, method
);
541 method
= aml_method(MEMORY_SLOT_EJECT_METHOD
, 2, AML_NOTSERIALIZED
);
543 Aml
*eject
= aml_name(MEMORY_SLOT_EJECT
);
545 aml_append(method
, aml_acquire(ctrl_lock
, 0xFFFF));
546 aml_append(method
, aml_store(aml_to_integer(slot_arg0
),
548 aml_append(method
, aml_store(one
, eject
));
549 aml_append(method
, aml_release(ctrl_lock
));
551 aml_append(mem_ctrl_dev
, method
);
553 aml_append(pci_scope
, mem_ctrl_dev
);
554 aml_append(ctx
, pci_scope
);
557 void build_memory_devices(Aml
*sb_scope
, int nr_mem
,
558 uint16_t io_base
, uint16_t io_len
)
568 /* build memory devices */
569 assert(nr_mem
<= ACPI_MAX_RAM_SLOTS
);
570 scope
= aml_scope("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE
);
572 aml_name_decl(MEMORY_SLOTS_NUMBER
, aml_int(nr_mem
))
575 crs
= aml_resource_template();
577 aml_io(AML_DECODE16
, io_base
, io_base
, 0, io_len
)
579 aml_append(scope
, aml_name_decl("_CRS", crs
));
581 aml_append(scope
, aml_operation_region(
582 MEMORY_HOTPLUG_IO_REGION
, AML_SYSTEM_IO
,
583 aml_int(io_base
), io_len
)
586 field
= aml_field(MEMORY_HOTPLUG_IO_REGION
, AML_DWORD_ACC
,
587 AML_NOLOCK
, AML_PRESERVE
);
588 aml_append(field
, /* read only */
589 aml_named_field(MEMORY_SLOT_ADDR_LOW
, 32));
590 aml_append(field
, /* read only */
591 aml_named_field(MEMORY_SLOT_ADDR_HIGH
, 32));
592 aml_append(field
, /* read only */
593 aml_named_field(MEMORY_SLOT_SIZE_LOW
, 32));
594 aml_append(field
, /* read only */
595 aml_named_field(MEMORY_SLOT_SIZE_HIGH
, 32));
596 aml_append(field
, /* read only */
597 aml_named_field(MEMORY_SLOT_PROXIMITY
, 32));
598 aml_append(scope
, field
);
600 field
= aml_field(MEMORY_HOTPLUG_IO_REGION
, AML_BYTE_ACC
,
601 AML_NOLOCK
, AML_WRITE_AS_ZEROS
);
602 aml_append(field
, aml_reserved_field(160 /* bits, Offset(20) */));
603 aml_append(field
, /* 1 if enabled, read only */
604 aml_named_field(MEMORY_SLOT_ENABLED
, 1));
606 /*(read) 1 if has a insert event. (write) 1 to clear event */
607 aml_named_field(MEMORY_SLOT_INSERT_EVENT
, 1));
609 /* (read) 1 if has a remove event. (write) 1 to clear event */
610 aml_named_field(MEMORY_SLOT_REMOVE_EVENT
, 1));
612 /* initiates device eject, write only */
613 aml_named_field(MEMORY_SLOT_EJECT
, 1));
614 aml_append(scope
, field
);
616 field
= aml_field(MEMORY_HOTPLUG_IO_REGION
, AML_DWORD_ACC
,
617 AML_NOLOCK
, AML_PRESERVE
);
618 aml_append(field
, /* DIMM selector, write only */
619 aml_named_field(MEMORY_SLOT_SLECTOR
, 32));
620 aml_append(field
, /* _OST event code, write only */
621 aml_named_field(MEMORY_SLOT_OST_EVENT
, 32));
622 aml_append(field
, /* _OST status code, write only */
623 aml_named_field(MEMORY_SLOT_OST_STATUS
, 32));
624 aml_append(scope
, field
);
625 aml_append(sb_scope
, scope
);
627 for (i
= 0; i
< nr_mem
; i
++) {
628 #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
631 dev
= aml_device("MP%02X", i
);
632 aml_append(dev
, aml_name_decl("_UID", aml_string("0x%02X", i
)));
633 aml_append(dev
, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
635 method
= aml_method("_CRS", 0, AML_NOTSERIALIZED
);
636 s
= BASEPATH MEMORY_SLOT_CRS_METHOD
;
637 aml_append(method
, aml_return(aml_call1(s
, aml_name("_UID"))));
638 aml_append(dev
, method
);
640 method
= aml_method("_STA", 0, AML_NOTSERIALIZED
);
641 s
= BASEPATH MEMORY_SLOT_STATUS_METHOD
;
642 aml_append(method
, aml_return(aml_call1(s
, aml_name("_UID"))));
643 aml_append(dev
, method
);
645 method
= aml_method("_PXM", 0, AML_NOTSERIALIZED
);
646 s
= BASEPATH MEMORY_SLOT_PROXIMITY_METHOD
;
647 aml_append(method
, aml_return(aml_call1(s
, aml_name("_UID"))));
648 aml_append(dev
, method
);
650 method
= aml_method("_OST", 3, AML_NOTSERIALIZED
);
651 s
= BASEPATH MEMORY_SLOT_OST_METHOD
;
653 aml_append(method
, aml_return(aml_call4(
654 s
, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
656 aml_append(dev
, method
);
658 method
= aml_method("_EJ0", 1, AML_NOTSERIALIZED
);
659 s
= BASEPATH MEMORY_SLOT_EJECT_METHOD
;
660 aml_append(method
, aml_return(aml_call2(
661 s
, aml_name("_UID"), aml_arg(0))));
662 aml_append(dev
, method
);
664 aml_append(sb_scope
, dev
);
667 /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
668 * If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
670 method
= aml_method(MEMORY_SLOT_NOTIFY_METHOD
, 2, AML_NOTSERIALIZED
);
671 for (i
= 0; i
< nr_mem
; i
++) {
672 ifctx
= aml_if(aml_equal(aml_arg(0), aml_int(i
)));
674 aml_notify(aml_name("MP%.02X", i
), aml_arg(1))
676 aml_append(method
, ifctx
);
678 aml_append(sb_scope
, method
);