Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Xen: Devel

[PATCH 5/7] vgabios: Reduce stack usage getting mode informations

 

 

Xen devel RSS feed   Index | Next | Previous | View Threaded


frediano.ziglio at citrix

May 1, 2012, 6:52 AM

Post #1 of 2 (41 views)
Permalink
[PATCH 5/7] vgabios: Reduce stack usage getting mode informations

Signed-off-by: Frediano Ziglio <frediano.ziglio [at] citrix>
---
tools/firmware/vgabios/vbe.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c
index fff314e..0b8b736 100644
--- a/tools/firmware/vgabios/vbe.c
+++ b/tools/firmware/vgabios/vbe.c
@@ -914,9 +914,9 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
// error by default is 0x014f which means supported but error
Bit16u result=0x014f;
Bit16u ss=get_SS();
- ModeInfoBlock info;
ModeInfoListItem *cur_info;
Boolean using_lfb;
+ ModeInfoBlockCompact info;

#ifdef DEBUG
printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX);
@@ -933,7 +933,6 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
#ifdef DEBUG
printf("VBE found mode %x\n",CX);
#endif
- memsetb(ss, &info, 0, sizeof(ModeInfoBlock));
memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact));
if (using_lfb) {
info.NumberOfBanks = 1;
@@ -950,6 +949,10 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
info.PhysBasePtr |= inw(VBE_DISPI_IOPORT_DATA);
#endif
result = 0x4f;
+
+ // copy updates in mode_info_block back
+ memsetb(ES, DI, 0, sizeof(ModeInfoBlock));
+ memcpyb(ES, DI, ss, &info, sizeof(info));
}
else
{
@@ -957,12 +960,6 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
printf("VBE *NOT* found mode %x\n",CX);
#endif
}
-
- if (result == 0x4f)
- {
- // copy updates in mode_info_block back
- memcpyb(ES, DI, ss, &info, sizeof(info));
- }

write_word(ss, AX, result);
}
--
1.7.5.4


_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel


frediano.ziglio at citrix

May 4, 2012, 5:36 AM

Post #2 of 2 (33 views)
Permalink
[PATCH 5/7] vgabios: Reduce stack usage getting mode informations [In reply to]

Informations are stored in a structure that is smaller than final one.
Previous code copy this structure to stack extending with zeroes then
update it and copy to caller while now the not-extended version is
copied into stack and then is extended during copy reducing stack
usage.

Signed-off-by: Frediano Ziglio <frediano.ziglio [at] citrix>
---
tools/firmware/vgabios/vbe.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c
index fff314e..0b8b736 100644
--- a/tools/firmware/vgabios/vbe.c
+++ b/tools/firmware/vgabios/vbe.c
@@ -914,9 +914,9 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
// error by default is 0x014f which means supported but error
Bit16u result=0x014f;
Bit16u ss=get_SS();
- ModeInfoBlock info;
ModeInfoListItem *cur_info;
Boolean using_lfb;
+ ModeInfoBlockCompact info;

#ifdef DEBUG
printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX);
@@ -933,7 +933,6 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
#ifdef DEBUG
printf("VBE found mode %x\n",CX);
#endif
- memsetb(ss, &info, 0, sizeof(ModeInfoBlock));
memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact));
if (using_lfb) {
info.NumberOfBanks = 1;
@@ -950,6 +949,10 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
info.PhysBasePtr |= inw(VBE_DISPI_IOPORT_DATA);
#endif
result = 0x4f;
+
+ // copy updates in mode_info_block back
+ memsetb(ES, DI, 0, sizeof(ModeInfoBlock));
+ memcpyb(ES, DI, ss, &info, sizeof(info));
}
else
{
@@ -957,12 +960,6 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
printf("VBE *NOT* found mode %x\n",CX);
#endif
}
-
- if (result == 0x4f)
- {
- // copy updates in mode_info_block back
- memcpyb(ES, DI, ss, &info, sizeof(info));
- }

write_word(ss, AX, result);
}
--
1.7.5.4


_______________________________________________
Xen-devel mailing list
Xen-devel [at] lists
http://lists.xen.org/xen-devel

Xen devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.