c412898169eab3603b8038079a55a8e89c6ee247
[platform/kernel/u-boot.git] / include / acpi / acpigen.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Core ACPI (Advanced Configuration and Power Interface) support
4  *
5  * Copyright 2019 Google LLC
6  *
7  * Modified from coreboot file acpigen.h
8  */
9
10 #ifndef __ACPI_ACPIGEN_H
11 #define __ACPI_ACPIGEN_H
12
13 #include <linux/types.h>
14
15 struct acpi_ctx;
16 struct acpi_gen_regaddr;
17 struct acpi_gpio;
18
19 /* Top 4 bits of the value used to indicate a three-byte length value */
20 #define ACPI_PKG_LEN_3_BYTES    0x80
21
22 #define ACPI_METHOD_NARGS_MASK          0x7
23 #define ACPI_METHOD_SERIALIZED_MASK     BIT(3)
24
25 #define ACPI_END_TAG                    0x79
26
27 /* ACPI Op/Prefix codes */
28 enum {
29         ZERO_OP                 = 0x00,
30         ONE_OP                  = 0x01,
31         NAME_OP                 = 0x08,
32         BYTE_PREFIX             = 0x0a,
33         WORD_PREFIX             = 0x0b,
34         DWORD_PREFIX            = 0x0c,
35         STRING_PREFIX           = 0x0d,
36         QWORD_PREFIX            = 0x0e,
37         SCOPE_OP                = 0x10,
38         BUFFER_OP               = 0x11,
39         PACKAGE_OP              = 0x12,
40         METHOD_OP               = 0x14,
41         SLEEP_OP                = 0x22,
42         DUAL_NAME_PREFIX        = 0x2e,
43         MULTI_NAME_PREFIX       = 0x2f,
44         DEBUG_OP                = 0x31,
45         EXT_OP_PREFIX           = 0x5b,
46         ROOT_PREFIX             = 0x5c,
47         LOCAL0_OP               = 0x60,
48         LOCAL1_OP               = 0x61,
49         LOCAL2_OP               = 0x62,
50         LOCAL3_OP               = 0x63,
51         LOCAL4_OP               = 0x64,
52         LOCAL5_OP               = 0x65,
53         LOCAL6_OP               = 0x66,
54         LOCAL7_OP               = 0x67,
55         ARG0_OP                 = 0x68,
56         ARG1_OP                 = 0x69,
57         ARG2_OP                 = 0x6a,
58         ARG3_OP                 = 0x6b,
59         ARG4_OP                 = 0x6c,
60         ARG5_OP                 = 0x6d,
61         ARG6_OP                 = 0x6e,
62         STORE_OP                = 0x70,
63         AND_OP                  = 0x7b,
64         OR_OP                   = 0x7d,
65         NOT_OP                  = 0x80,
66         DEVICE_OP               = 0x82,
67         POWER_RES_OP            = 0x84,
68         LEQUAL_OP               = 0x93,
69         TO_BUFFER_OP            = 0x96,
70         TO_INTEGER_OP           = 0x99,
71         IF_OP                   = 0xa0,
72         ELSE_OP                 = 0xa1,
73         RETURN_OP               = 0xa4,
74 };
75
76 /**
77  * enum psd_coord - Coordination types for P-states
78  *
79  * The type of coordination that exists (hardware) or is required (software) as
80  * a result of the underlying hardware dependency
81  */
82 enum psd_coord {
83         SW_ALL = 0xfc,
84         SW_ANY = 0xfd,
85         HW_ALL = 0xfe
86 };
87
88 /**
89  * acpigen_get_current() - Get the current ACPI code output pointer
90  *
91  * @ctx: ACPI context pointer
92  * @return output pointer
93  */
94 u8 *acpigen_get_current(struct acpi_ctx *ctx);
95
96 /**
97  * acpigen_emit_byte() - Emit a byte to the ACPI code
98  *
99  * @ctx: ACPI context pointer
100  * @data: Value to output
101  */
102 void acpigen_emit_byte(struct acpi_ctx *ctx, uint data);
103
104 /**
105  * acpigen_emit_word() - Emit a 16-bit word to the ACPI code
106  *
107  * @ctx: ACPI context pointer
108  * @data: Value to output
109  */
110 void acpigen_emit_word(struct acpi_ctx *ctx, uint data);
111
112 /**
113  * acpigen_emit_dword() - Emit a 32-bit 'double word' to the ACPI code
114  *
115  * @ctx: ACPI context pointer
116  * @data: Value to output
117  */
118 void acpigen_emit_dword(struct acpi_ctx *ctx, uint data);
119
120 /**
121  * acpigen_emit_stream() - Emit a stream of bytes
122  *
123  * @ctx: ACPI context pointer
124  * @data: Data to output
125  * @size: Size of data in bytes
126  */
127 void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size);
128
129 /**
130  * acpigen_emit_string() - Emit a string
131  *
132  * Emit a string with a null terminator
133  *
134  * @ctx: ACPI context pointer
135  * @str: String to output, or NULL for an empty string
136  */
137 void acpigen_emit_string(struct acpi_ctx *ctx, const char *str);
138
139 /**
140  * acpigen_write_len_f() - Write a 'forward' length placeholder
141  *
142  * This adds space for a length value in the ACPI stream and pushes the current
143  * position (before the length) on the stack. After calling this you can write
144  * some data and then call acpigen_pop_len() to update the length value.
145  *
146  * Usage:
147  *
148  *    acpigen_write_len_f() ------\
149  *    acpigen_write...()          |
150  *    acpigen_write...()          |
151  *      acpigen_write_len_f() --\ |
152  *      acpigen_write...()      | |
153  *      acpigen_write...()      | |
154  *      acpigen_pop_len() ------/ |
155  *    acpigen_write...()          |
156  *    acpigen_pop_len() ----------/
157  *
158  * See ACPI 6.3 section 20.2.4 Package Length Encoding
159  *
160  * This implementation always uses a 3-byte packet length for simplicity. It
161  * could be adjusted to support other lengths.
162  *
163  * @ctx: ACPI context pointer
164  */
165 void acpigen_write_len_f(struct acpi_ctx *ctx);
166
167 /**
168  * acpigen_pop_len() - Update the previously stacked length placeholder
169  *
170  * Call this after the data for the block has been written. It updates the
171  * top length value in the stack and pops it off.
172  *
173  * @ctx: ACPI context pointer
174  */
175 void acpigen_pop_len(struct acpi_ctx *ctx);
176
177 /**
178  * acpigen_write_package() - Start writing a package
179  *
180  * A package collects together a number of elements in the ACPI code. To write
181  * a package use:
182  *
183  * acpigen_write_package(ctx, 3);
184  * ...write things
185  * acpigen_pop_len()
186  *
187  * If you don't know the number of elements in advance, acpigen_write_package()
188  * returns a pointer to the value so you can update it later:
189  *
190  * char *num_elements = acpigen_write_package(ctx, 0);
191  * ...write things
192  * *num_elements += 1;
193  * ...write things
194  * *num_elements += 1;
195  * acpigen_pop_len()
196  *
197  * @ctx: ACPI context pointer
198  * @nr_el: Number of elements (0 if not known)
199  * @returns pointer to the number of elements, which can be updated by the
200  *      caller if needed
201  */
202 char *acpigen_write_package(struct acpi_ctx *ctx, int nr_el);
203
204 /**
205  * acpigen_write_byte() - Write a byte
206  *
207  * @ctx: ACPI context pointer
208  * @data: Value to write
209  */
210 void acpigen_write_byte(struct acpi_ctx *ctx, unsigned int data);
211
212 /**
213  * acpigen_write_word() - Write a word
214  *
215  * @ctx: ACPI context pointer
216  * @data: Value to write
217  */
218 void acpigen_write_word(struct acpi_ctx *ctx, unsigned int data);
219
220 /**
221  * acpigen_write_dword() - Write a dword
222  *
223  * @ctx: ACPI context pointer
224  * @data: Value to write
225  */
226 void acpigen_write_dword(struct acpi_ctx *ctx, unsigned int data);
227
228 /**
229  * acpigen_write_qword() - Write a qword
230  *
231  * @ctx: ACPI context pointer
232  * @data: Value to write
233  */
234 void acpigen_write_qword(struct acpi_ctx *ctx, u64 data);
235
236 /**
237  * acpigen_write_zero() - Write zero
238  *
239  * @ctx: ACPI context pointer
240  */
241 void acpigen_write_zero(struct acpi_ctx *ctx);
242
243 /**
244  * acpigen_write_one() - Write one
245  *
246  * @ctx: ACPI context pointer
247  */
248 void acpigen_write_one(struct acpi_ctx *ctx);
249
250 /**
251  * acpigen_write_integer() - Write an integer
252  *
253  * This writes an operation (BYTE_OP, WORD_OP, DWORD_OP, QWORD_OP depending on
254  * the integer size) and an integer value. Note that WORD means 16 bits in ACPI.
255  *
256  * @ctx: ACPI context pointer
257  * @data: Integer to write
258  */
259 void acpigen_write_integer(struct acpi_ctx *ctx, u64 data);
260
261 /**
262  * acpigen_write_name_zero() - Write a named zero value
263  *
264  * @ctx: ACPI context pointer
265  * @name: Name of the value
266  */
267 void acpigen_write_name_zero(struct acpi_ctx *ctx, const char *name);
268
269 /**
270  * acpigen_write_name_one() - Write a named one value
271  *
272  * @ctx: ACPI context pointer
273  * @name: Name of the value
274  */
275 void acpigen_write_name_one(struct acpi_ctx *ctx, const char *name);
276
277 /**
278  * acpigen_write_name_byte() - Write a named byte value
279  *
280  * @ctx: ACPI context pointer
281  * @name: Name of the value
282  * @val: Value to write
283  */
284 void acpigen_write_name_byte(struct acpi_ctx *ctx, const char *name, uint val);
285
286 /**
287  * acpigen_write_name_word() - Write a named word value
288  *
289  * @ctx: ACPI context pointer
290  * @name: Name of the value
291  * @val: Value to write
292  */
293 void acpigen_write_name_word(struct acpi_ctx *ctx, const char *name, uint val);
294
295 /**
296  * acpigen_write_name_dword() - Write a named dword value
297  *
298  * @ctx: ACPI context pointer
299  * @name: Name of the value
300  * @val: Value to write
301  */
302 void acpigen_write_name_dword(struct acpi_ctx *ctx, const char *name, uint val);
303
304 /**
305  * acpigen_write_name_qword() - Write a named qword value
306  *
307  * @ctx: ACPI context pointer
308  * @name: Name of the value
309  * @val: Value to write
310  */
311 void acpigen_write_name_qword(struct acpi_ctx *ctx, const char *name, u64 val);
312
313 /**
314  * acpigen_write_name_integer() - Write a named integer value
315  *
316  * @ctx: ACPI context pointer
317  * @name: Name of the value
318  * @val: Value to write
319  */
320 void acpigen_write_name_integer(struct acpi_ctx *ctx, const char *name,
321                                 u64 val);
322
323 /**
324  * acpigen_write_name_string() - Write a named string value
325  *
326  * @ctx: ACPI context pointer
327  * @name: Name of the value
328  * @string: String to write
329  */
330 void acpigen_write_name_string(struct acpi_ctx *ctx, const char *name,
331                                const char *string);
332
333 /**
334  * acpigen_write_string() - Write a string
335  *
336  * This writes a STRING_PREFIX followed by a null-terminated string
337  *
338  * @ctx: ACPI context pointer
339  * @str: String to write
340  */
341 void acpigen_write_string(struct acpi_ctx *ctx, const char *str);
342
343 /**
344  * acpigen_emit_namestring() - Emit an ACPI name
345  *
346  * This writes out an ACPI name or path in the required special format. It does
347  * not add the NAME_OP prefix.
348  *
349  * @ctx: ACPI context pointer
350  * @namepath: Name / path to emit
351  */
352 void acpigen_emit_namestring(struct acpi_ctx *ctx, const char *namepath);
353
354 /**
355  * acpigen_write_name() - Write out an ACPI name
356  *
357  * This writes out an ACPI name or path in the required special format with a
358  * NAME_OP prefix.
359  *
360  * @ctx: ACPI context pointer
361  * @namepath: Name / path to emit
362  */
363 void acpigen_write_name(struct acpi_ctx *ctx, const char *namepath);
364
365 /**
366  * acpigen_write_scope() - Write a scope
367  *
368  * @ctx: ACPI context pointer
369  * @scope: Scope to write (e.g. "\\_SB.ABCD")
370  */
371 void acpigen_write_scope(struct acpi_ctx *ctx, const char *scope);
372
373 /**
374  * acpigen_write_uuid() - Write a UUID
375  *
376  * This writes out a UUID in the format used by ACPI, with a BUFFER_OP prefix.
377  *
378  * @ctx: ACPI context pointer
379  * @uuid: UUID to write in the form aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
380  * @return 0 if OK, -EINVAL if the format is incorrect
381  */
382 int acpigen_write_uuid(struct acpi_ctx *ctx, const char *uuid);
383
384 /**
385  * acpigen_emit_ext_op() - Emit an extended op with the EXT_OP_PREFIX prefix
386  *
387  * @ctx: ACPI context pointer
388  * @op: Operation code (e.g. SLEEP_OP)
389  */
390 void acpigen_emit_ext_op(struct acpi_ctx *ctx, uint op);
391
392 /**
393  * acpigen_write_method() - Write a method header
394  *
395  * @ctx: ACPI context pointer
396  * @name: Method name (4 characters)
397  * @nargs: Number of method arguments (0 if none)
398  */
399 void acpigen_write_method(struct acpi_ctx *ctx, const char *name, int nargs);
400
401 /**
402  * acpigen_write_method_serialized() - Write a method header
403  *
404  * This sets the 'serialized' flag so that the method is thread-safe
405  *
406  * @ctx: ACPI context pointer
407  * @name: Method name (4 characters)
408  * @nargs: Number of method arguments (0 if none)
409  */
410 void acpigen_write_method_serialized(struct acpi_ctx *ctx, const char *name,
411                                      int nargs);
412
413 /**
414  * acpigen_write_device() - Write an ACPI device
415  *
416  * @ctx: ACPI context pointer
417  * @name: Device name to write
418  */
419 void acpigen_write_device(struct acpi_ctx *ctx, const char *name);
420
421 /**
422  * acpigen_write_sta() - Write a _STA method
423  *
424  * @ctx: ACPI context pointer
425  * @status: Status value to return
426  */
427 void acpigen_write_sta(struct acpi_ctx *ctx, uint status);
428
429 /**
430  * acpigen_write_resourcetemplate_header() - Write a ResourceTemplate header
431  *
432  * @ctx: ACPI context pointer
433  */
434 void acpigen_write_resourcetemplate_header(struct acpi_ctx *ctx);
435
436 /**
437  * acpigen_write_resourcetemplate_footer() - Write a ResourceTemplate footer
438  *
439  * @ctx: ACPI context pointer
440  */
441 void acpigen_write_resourcetemplate_footer(struct acpi_ctx *ctx);
442
443 /**
444  * acpigen_write_register_resource() - Write a register resource
445  *
446  * This writes a header, the address information and a footer
447  *
448  * @ctx: ACPI context pointer
449  * @addr: Address to write
450  */
451 void acpigen_write_register_resource(struct acpi_ctx *ctx,
452                                      const struct acpi_gen_regaddr *addr);
453
454 /**
455  * acpigen_write_sleep() - Write a sleep operation
456  *
457  * @ctx: ACPI context pointer
458  * @sleep_ms: Number of milliseconds to sleep for
459  */
460 void acpigen_write_sleep(struct acpi_ctx *ctx, u64 sleep_ms);
461
462 /**
463  * acpigen_write_store() - Write a store operation
464  *
465  * @ctx: ACPI context pointer
466  */
467 void acpigen_write_store(struct acpi_ctx *ctx);
468
469 /**
470  * acpigen_write_debug_string() - Write a debug string
471  *
472  * This writes a debug operation with an associated string
473  *
474  * @ctx: ACPI context pointer
475  * @str: String to write
476  */
477 void acpigen_write_debug_string(struct acpi_ctx *ctx, const char *str);
478
479 /**
480  * acpigen_write_or() - Write a bitwise OR operation
481  *
482  * res = arg1 | arg2
483  *
484  * @ctx: ACPI context pointer
485  * @arg1: ACPI opcode for operand 1 (e.g. LOCAL0_OP)
486  * @arg2: ACPI opcode for operand 2 (e.g. LOCAL1_OP)
487  * @res: ACPI opcode for result (e.g. LOCAL2_OP)
488  */
489 void acpigen_write_or(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res);
490
491 /**
492  * acpigen_write_and() - Write a bitwise AND operation
493  *
494  * res = arg1 & arg2
495  *
496  * @ctx: ACPI context pointer
497  * @arg1: ACPI opcode for operand 1 (e.g. LOCAL0_OP)
498  * @arg2: ACPI opcode for operand 2 (e.g. LOCAL1_OP)
499  * @res: ACPI opcode for result (e.g. LOCAL2_OP)
500  */
501 void acpigen_write_and(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res);
502
503 /**
504  * acpigen_write_not() - Write a bitwise NOT operation
505  *
506  * res = ~arg1
507  *
508  * @ctx: ACPI context pointer
509  * @arg: ACPI opcode for operand (e.g. LOCAL0_OP)
510  * @res: ACPI opcode for result (e.g. LOCAL2_OP)
511  */
512 void acpigen_write_not(struct acpi_ctx *ctx, u8 arg, u8 res);
513
514 /**
515  * acpigen_write_power_res() - Write a power resource
516  *
517  * Name (_PRx, Package(One) { name })
518  * ...
519  * PowerResource (name, level, order)
520  *
521  * The caller should fill in the rest of the power resource and then call
522  * acpigen_pop_len() to close it off
523  *
524  * @ctx: ACPI context pointer
525  * @name: Name of power resource (e.g. "PRIC")
526  * @level: Deepest sleep level that this resource must be kept on (0=S0, 3=S3)
527  * @order: Order that this must be enabled/disabled (e.g. 0)
528  * @dev_stats: List of states to define, e.g. {"_PR0", "_PR3"}
529  * @dev_states_count: Number of dev states
530  */
531 void acpigen_write_power_res(struct acpi_ctx *ctx, const char *name, uint level,
532                              uint order, const char *const dev_states[],
533                              size_t dev_states_count);
534
535 /**
536  * acpigen_set_enable_tx_gpio() - Emit ACPI code to enable/disable a GPIO
537  *
538  * This emits code to either enable to disable a Tx GPIO. It takes account of
539  * the GPIO polarity.
540  *
541  * The code needs access to the DW0 register for the pad being used. This is
542  * provided by gpio->pin0_addr and ACPI methods must be defined for the board
543  * which can read and write the pad's DW0 register given this address:
544  *    @dw0_read: takes a single argument, the DW0 address
545  *               returns the DW0 value
546  *    @dw0:write: takes two arguments, the DW0 address and the value to write
547  *               no return value
548  *
549  * Example code (-- means comment):
550  *
551  *      -- Get Pad Configuration DW0 register value
552  *      Method (GPC0, 0x1, Serialized)
553  *      {
554  *              -- Arg0 - GPIO DW0 address
555  *              Store (Arg0, Local0)
556  *              OperationRegion (PDW0, SystemMemory, Local0, 4)
557  *              Field (PDW0, AnyAcc, NoLock, Preserve) {
558  *                      TEMP, 32
559  *              }
560  *              Return (TEMP)
561  *      }
562  *
563  *      -- Set Pad Configuration DW0 register value
564  *      Method (SPC0, 0x2, Serialized)
565  *      {
566  *              -- Arg0 - GPIO DW0 address
567  *              -- Arg1 - Value for DW0 register
568  *              Store (Arg0, Local0)
569  *              OperationRegion (PDW0, SystemMemory, Local0, 4)
570  *              Field (PDW0, AnyAcc, NoLock, Preserve) {
571  *                      TEMP,32
572  *              }
573  *              Store (Arg1, TEMP)
574  *      }
575  *
576  *
577  * @ctx: ACPI context pointer
578  * @tx_state_val: Mask to use to toggle the TX state on the GPIO pin, e,g.
579  *      PAD_CFG0_TX_STATE
580  * @dw0_read: Method name to use to read dw0, e.g. "\\_SB.GPC0"
581  * @dw0_write: Method name to use to read dw0, e.g. "\\_SB.SPC0"
582  * @gpio: GPIO to change
583  * @enable: true to enable GPIO, false to disable
584  * Returns 0 on success, -ve on error.
585  */
586 int acpigen_set_enable_tx_gpio(struct acpi_ctx *ctx, u32 tx_state_val,
587                                const char *dw0_read, const char *dw0_write,
588                                struct acpi_gpio *gpio, bool enable);
589
590 /**
591  * acpigen_write_prw() - Write a power resource for wake (_PRW)
592  *
593  * @ctx: ACPI context pointer
594  * @wake: GPE that wakes up the device
595  * @level: Deepest power system sleeping state that can be entered while still
596  *      providing wake functionality
597  */
598 void acpigen_write_prw(struct acpi_ctx *ctx, uint wake, uint level);
599
600 /**
601  * acpigen_write_if() - Write an If block
602  *
603  * This requires a call to acpigen_pop_len() to complete the block
604  *
605  * @ctx: ACPI context pointer
606  */
607 void acpigen_write_if(struct acpi_ctx *ctx);
608
609 /**
610  * acpigen_write_if_lequal_op_int() - Write comparison between op and integer
611  *
612  * Generates ACPI code for checking if operand1 and operand2 are equal
613  *
614  * If (Lequal (op, val))
615  *
616  * @ctx: ACPI context pointer
617  * @op: Operand to check
618  * @val: Value to check against
619  */
620 void acpigen_write_if_lequal_op_int(struct acpi_ctx *ctx, uint op, u64 val);
621
622 /**
623  * acpigen_write_else() - Write an Ef block
624  *
625  * This requires a call to acpigen_pop_len() to complete the block
626  *
627  * @ctx: ACPI context pointer
628  */
629 void acpigen_write_else(struct acpi_ctx *ctx);
630
631 /**
632  * acpigen_write_to_buffer() - Write a ToBuffer operation
633  *
634  * E.g.: to generate: ToBuffer (Arg0, Local0)
635  * use acpigen_write_to_buffer(ctx, ARG0_OP, LOCAL0_OP)
636  *
637  * @ctx: ACPI context pointer
638  * @src: Source argument
639  * @dst: Destination argument
640  */
641 void acpigen_write_to_buffer(struct acpi_ctx *ctx, uint src, uint dst);
642
643 /**
644  * acpigen_write_to_integer() - Write a ToInteger operation
645  *
646  * E.g.: to generate: ToInteger (Arg0, Local0)
647  * use acpigen_write_to_integer(ctx, ARG0_OP, LOCAL0_OP)
648  *
649  * @ctx: ACPI context pointer
650  * @src: Source argument
651  * @dst: Destination argument
652  */
653 void acpigen_write_to_integer(struct acpi_ctx *ctx, uint src, uint dst);
654
655 /**
656  * acpigen_write_return_byte_buffer() - Write a return of a byte buffer
657  *
658  * @ctx: ACPI context pointer
659  * @arr: Array of bytes to return
660  * @size: Number of bytes
661  */
662 void acpigen_write_return_byte_buffer(struct acpi_ctx *ctx, u8 *arr,
663                                       size_t size);
664
665 /**
666  * acpigen_write_return_singleton_buffer() - Write a return of a 1-byte buffer
667  *
668  * @ctx: ACPI context pointer
669  * @arg: Byte to return
670  */
671 void acpigen_write_return_singleton_buffer(struct acpi_ctx *ctx, uint arg);
672
673 /**
674  * acpigen_write_return_byte() - Write a return of a byte
675  *
676  * @ctx: ACPI context pointer
677  * @arg: Byte to return
678  */
679 void acpigen_write_return_byte(struct acpi_ctx *ctx, uint arg);
680
681 /**
682  * acpigen_write_dsm_start() - Start a _DSM method
683  *
684  * Generate ACPI AML code to start the _DSM method.
685  *
686  * The functions need to be called in the correct sequence as below.
687  *
688  * Within the <generate-code-here> region, Local0 and Local1 must be are left
689  * untouched, but Local2-Local7 can be used
690  *
691  * Arguments passed into _DSM method:
692  * Arg0 = UUID
693  * Arg1 = Revision
694  * Arg2 = Function index
695  * Arg3 = Function-specific arguments
696  *
697  * AML code generated looks like this:
698  * Method (_DSM, 4, Serialized) {   -- acpigen_write_dsm_start)
699  *      ToBuffer (Arg0, Local0)
700  *      If (LEqual (Local0, ToUUID(uuid))) {  -- acpigen_write_dsm_uuid_start
701  *              ToInteger (Arg2, Local1)
702  *              If (LEqual (Local1, 0)) {  -- acpigen_write_dsm_uuid_start_cond
703  *                      <generate-code-here>
704  *              }                          -- acpigen_write_dsm_uuid_end_cond
705  *              ...
706  *              If (LEqual (Local1, n)) {  -- acpigen_write_dsm_uuid_start_cond
707  *                      <generate-code-here>
708  *              }                          -- acpigen_write_dsm_uuid_end_cond
709  *              Return (Buffer (One) { 0x0 })
710  *      }                                  -- acpigen_write_dsm_uuid_end
711  *      ...
712  *      If (LEqual (Local0, ToUUID(uuidn))) {
713  *      ...
714  *      }
715  *      Return (Buffer (One) { 0x0 })  -- acpigen_write_dsm_end
716  * }
717  *
718  * @ctx: ACPI context pointer
719  */
720 void acpigen_write_dsm_start(struct acpi_ctx *ctx);
721
722 /**
723  * acpigen_write_dsm_uuid_start() - Start a new UUID block
724  *
725  * This starts generation of code to handle a particular UUID:
726  *
727  *      If (LEqual (Local0, ToUUID(uuid))) {
728  *              ToInteger (Arg2, Local1)
729  *
730  * @ctx: ACPI context pointer
731  */
732 int acpigen_write_dsm_uuid_start(struct acpi_ctx *ctx, const char *uuid);
733
734 /**
735  * acpigen_write_dsm_uuid_start_cond() - Start a new condition block
736  *
737  * This starts generation of condition-checking code to handle a particular
738  * function:
739  *
740  *              If (LEqual (Local1, i))
741  *
742  * @ctx: ACPI context pointer
743  */
744 void acpigen_write_dsm_uuid_start_cond(struct acpi_ctx *ctx, int seq);
745
746 /**
747  * acpigen_write_dsm_uuid_end_cond() - Start a new condition block
748  *
749  * This ends generation of condition-checking code to handle a particular
750  * function:
751  *
752  *              }
753  *
754  * @ctx: ACPI context pointer
755  */
756 void acpigen_write_dsm_uuid_end_cond(struct acpi_ctx *ctx);
757
758 /**
759  * acpigen_write_dsm_uuid_end() - End a UUID block
760  *
761  * This ends generation of code to handle a particular UUID:
762  *
763  *              Return (Buffer (One) { 0x0 })
764  *
765  * @ctx: ACPI context pointer
766  */
767 void acpigen_write_dsm_uuid_end(struct acpi_ctx *ctx);
768
769 /**
770  * acpigen_write_dsm_end() - End a _DSM method
771  *
772  * This ends generates of the _DSM block:
773  *
774  *      Return (Buffer (One) { 0x0 })
775  *
776  * @ctx: ACPI context pointer
777  */
778 void acpigen_write_dsm_end(struct acpi_ctx *ctx);
779
780 #endif