1 // Code for handling calls to "post" that are resume related.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU LGPLv3 license.
7 #include "util.h" // dprintf
8 #include "ioport.h" // outb
9 #include "pic.h" // eoi_pic2
10 #include "biosvar.h" // struct bios_data_area_s
11 #include "bregs.h" // struct bregs
12 #include "acpi.h" // find_resume_vector
14 // Reset DMA controller
18 // first reset the DMA controllers
19 outb(0, PORT_DMA1_MASTER_CLEAR);
20 outb(0, PORT_DMA2_MASTER_CLEAR);
22 // then initialize the DMA controllers
23 outb(0xc0, PORT_DMA2_MODE_REG);
24 outb(0x00, PORT_DMA2_MASK_REG);
27 // Handler for post calls that look like a resume.
29 handle_resume(u8 status)
34 dprintf(1, "In resume (status=%d)\n", status);
36 struct bios_data_area_s *bda = MAKE_FARPTR(SEG_BDA, 0);
39 if (CONFIG_S3_RESUME) {
40 // S3 resume request. Jump to 32bit mode to handle the resume.
44 "pushl $_code32_s3_resume\n"
46 : : "i"(BUILD_S3RESUME_STACK_ADDR), "a"(0)
55 // Normal post - now that status has been cleared a reset will
56 // run regular boot code..
61 // flush keyboard (issue EOI) and jump via 40h:0067h
65 // resume execution by jump via 40h:0067h
69 : : "m"(bda->jump_ip), "a"(SEG_BDA)
74 // resume execution via IRET via 40h:0067h
80 : : "m"(bda->jump_ip), "m"(bda->jump_cs), "a"(SEG_BDA)
85 // resume execution via RETF via 40h:0067h
91 : : "m"(bda->jump_ip), "m"(bda->jump_cs), "a"(SEG_BDA)
96 BX_PANIC("Unimplemented shutdown status: %02x\n", status);
102 if (!CONFIG_S3_RESUME)
103 BX_PANIC("S3 resume support not compiled in.\n");
105 dprintf(1, "In 32bit resume\n");
109 make_bios_readonly();
111 u32 s3_resume_vector = find_resume_vector();
113 // Invoke the resume vector.
115 memset(&br, 0, sizeof(br));
116 if (s3_resume_vector) {
117 dprintf(1, "Jump to resume vector (%x)\n", s3_resume_vector);
118 br.ip = FARPTR_TO_OFFSET(s3_resume_vector);
119 br.cs = FARPTR_TO_SEG(s3_resume_vector);
121 dprintf(1, "No resume vector set!\n");
122 // Jump to the post vector to restart with a normal boot.
123 br.ip = (u32)reset_vector - BUILD_BIOS_ADDR;
129 // Ughh - some older gcc compilers have a bug which causes VISIBLE32
130 // functions to not be exported as global variables.
131 asm(".global s3_resume");