Check-in [dc202cee4b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixed bugs in c++-style casts
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:dc202cee4b82ed321218d40f866ff36946046654
User & Date: maxi 2018-11-13 06:34:46
Context
2018-11-13
06:38
Added trunk's greeter check-in: 113d0291b5 user: maxi tags: trunk
06:34
fixed bugs in c++-style casts check-in: dc202cee4b user: maxi tags: trunk
2018-11-12
12:56
Changed more C-Style Casts check-in: 5f36b15924 user: maxi tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/acpi/wrappers.cpp.

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
    return nullptr;
}

void madt_wrapper::reset_entry_pointer() { offset = 0; }

inline void sdt_wrapper::set_rsdp(void *ptr)
{
    SDT::RSDP *rsdpptr = reinterpret_cast<SDT::RSDP *>ptr;
    acpi_version = rsdpptr->Revision;
    if (UTILS::is_rsdp_v2(rsdpptr->Revision))
    {
        rsdp_20_ptr = reinterpret_cast<SDT::RSDP20 *>ptr;
        rsdp_ptr = rsdpptr;
    }
    else
    {
        rsdp_20_ptr = NULL;
        rsdp_ptr = rsdpptr;
    }
................................................................................
    if (acpi_version > 1)
        return (xsdt_ptr->h.Length - sizeof(SDT::generic_sdt) - 1) / 8;
    return (rsdt_ptr->h.Length - sizeof(SDT::generic_sdt) - 1) / 4;
}

void sdt_wrapper::set_rsdt(uint32_t physical_position)
{
    rsdt_ptr = reinterpret_cast<SDT::RSDT *>physical_position;
}

void sdt_wrapper::set_xsdt(uint32_t ptr)
{
    if (acpi_version > 1)
        xsdt_ptr = reinterpret_cast<SDT::XSDT *>ptr;
}

sdt_wrapper::sdt_wrapper()
{
    rsdp_ptr = UTILS::find_rsdp();
    if (rsdp_ptr == nullptr)
        Exception::kernel_panic("ACPI: no rsdp found, initialization of ACPI not "
................................................................................
    if (acpi_version != 0)
        return reinterpret_cast<SDT::generic_sdt *>(xsdt_ptr->PointerToOtherSDT[index]);
    return reinterpret_cast<SDT::generic_sdt *>(rsdt_ptr->PointerToOtherSDT[index]);
}

void sdt_wrapper::set_fadt()
{
    fadt = fadt_wrapper(reinterpret_cast<SDT::FADT *>get_table(0));
}

void sdt_wrapper::set_dsdt() 
{
    dsdt = dsdt_wrapper ((SDT::DSDT*) fadt.stored->Dsdt);
}

void sdt_wrapper::find_structures()
{
    set_fadt();
    set_dsdt();
    for (size_t i = 0; ft.all_found(); ++i)
    {
        SDT::generic_sdt *a = get_table(i);
        if (memcmp(a->Signature, "APIC", 4) == 0)
        {
            madt = madt_wrapper(reinterpret_cast<SDT::MADT *>a);
            ft.APIC = true;
        }
    }
}

dsdt_wrapper::dsdt_wrapper(SDT::DSDT *other) { stored = other; }
dsdt_wrapper::dsdt_wrapper() { stored = nullptr; }

ksdk::string_view dsdt_wrapper::getCode()
{
    size_t length = stored->h.Length - sizeof(SDT::generic_sdt);
    char *start = reinterpret_cast<char *>stored->DefinitionBlock;
    return ksdk::string_view(start, length);
}

fadt_wrapper::fadt_wrapper(SDT::FADT *ptr) : stored(ptr)
{
    *&(stored->Reserved) = 0;
}

fadt_wrapper::fadt_wrapper() : stored(nullptr)
{
}

SDT::DSDT *fadt_wrapper::get_dsdt() { return reinterpret_cast<SDT::DSDT *>stored->Dsdt; }

void fadt_wrapper::enable_acpi()
{
    outb(stored->SMI_CommandPort, stored->AcpiEnable);
    while (inw(stored->PM1aControlBlock) & 1 == 0);
}

void fadt_wrapper::disable_acpi()
{
    outb(stored->SMI_CommandPort, stored->AcpiDisable);
}

} // namespace ACPI






|



|







 







|





|







 







|




|











|











|












|













52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
    return nullptr;
}

void madt_wrapper::reset_entry_pointer() { offset = 0; }

inline void sdt_wrapper::set_rsdp(void *ptr)
{
    SDT::RSDP *rsdpptr = reinterpret_cast<SDT::RSDP *>(ptr);
    acpi_version = rsdpptr->Revision;
    if (UTILS::is_rsdp_v2(rsdpptr->Revision))
    {
        rsdp_20_ptr = reinterpret_cast<SDT::RSDP20 *>(ptr);
        rsdp_ptr = rsdpptr;
    }
    else
    {
        rsdp_20_ptr = NULL;
        rsdp_ptr = rsdpptr;
    }
................................................................................
    if (acpi_version > 1)
        return (xsdt_ptr->h.Length - sizeof(SDT::generic_sdt) - 1) / 8;
    return (rsdt_ptr->h.Length - sizeof(SDT::generic_sdt) - 1) / 4;
}

void sdt_wrapper::set_rsdt(uint32_t physical_position)
{
    rsdt_ptr = reinterpret_cast<SDT::RSDT *>(physical_position);
}

void sdt_wrapper::set_xsdt(uint32_t ptr)
{
    if (acpi_version > 1)
        xsdt_ptr = reinterpret_cast<SDT::XSDT *>(ptr);
}

sdt_wrapper::sdt_wrapper()
{
    rsdp_ptr = UTILS::find_rsdp();
    if (rsdp_ptr == nullptr)
        Exception::kernel_panic("ACPI: no rsdp found, initialization of ACPI not "
................................................................................
    if (acpi_version != 0)
        return reinterpret_cast<SDT::generic_sdt *>(xsdt_ptr->PointerToOtherSDT[index]);
    return reinterpret_cast<SDT::generic_sdt *>(rsdt_ptr->PointerToOtherSDT[index]);
}

void sdt_wrapper::set_fadt()
{
    fadt = fadt_wrapper(reinterpret_cast<SDT::FADT *>(get_table(0)));
}

void sdt_wrapper::set_dsdt() 
{
    dsdt = dsdt_wrapper (reinterpret_cast<SDT::DSDT*> (fadt.stored->Dsdt));
}

void sdt_wrapper::find_structures()
{
    set_fadt();
    set_dsdt();
    for (size_t i = 0; ft.all_found(); ++i)
    {
        SDT::generic_sdt *a = get_table(i);
        if (memcmp(a->Signature, "APIC", 4) == 0)
        {
            madt = madt_wrapper(reinterpret_cast<SDT::MADT *>(a));
            ft.APIC = true;
        }
    }
}

dsdt_wrapper::dsdt_wrapper(SDT::DSDT *other) { stored = other; }
dsdt_wrapper::dsdt_wrapper() { stored = nullptr; }

ksdk::string_view dsdt_wrapper::getCode()
{
    size_t length = stored->h.Length - sizeof(SDT::generic_sdt);
    char *start = reinterpret_cast<char *> (stored->DefinitionBlock);
    return ksdk::string_view(start, length);
}

fadt_wrapper::fadt_wrapper(SDT::FADT *ptr) : stored(ptr)
{
    *&(stored->Reserved) = 0;
}

fadt_wrapper::fadt_wrapper() : stored(nullptr)
{
}

SDT::DSDT *fadt_wrapper::get_dsdt() { return reinterpret_cast<SDT::DSDT *> (stored->Dsdt); }

void fadt_wrapper::enable_acpi()
{
    outb(stored->SMI_CommandPort, stored->AcpiEnable);
    while (inw(stored->PM1aControlBlock) & 1 == 0);
}

void fadt_wrapper::disable_acpi()
{
    outb(stored->SMI_CommandPort, stored->AcpiDisable);
}

} // namespace ACPI

Changes to src/buffers/vga_buffer.cpp.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	text_cursor = 0;
	text_color = make_color_mode(color::WHITE);
}

void initialize_buffers()
{

	buffer = ksdk::buffer<char>(reinterpret_cast<char *>0x000A0000, reinterpret_cast<char *>0x000BFFFF);
	text_buffer = ksdk::buffer<character>(reinterpret_cast<character *>0x000B8000,
										  TEXT_WIDTH * TEXT_HEIGHT);
}

void initialize()
{
	initialize_variables();
	initialize_buffers();






|
|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	text_cursor = 0;
	text_color = make_color_mode(color::WHITE);
}

void initialize_buffers()
{

	buffer = ksdk::buffer<char>(reinterpret_cast<char *>(0x000A0000), reinterpret_cast<char *>(0x000BFFFF));
	text_buffer = ksdk::buffer<character>(reinterpret_cast<character *>(0x000B8000),
										  TEXT_WIDTH * TEXT_HEIGHT);
}

void initialize()
{
	initialize_variables();
	initialize_buffers();